import java.util.*;
class Array
{
    Scanner in()
    {   return new Scanner(System.in);  }

    void out(String n)
    {   System.out.print(n);    }

    int[] getarray(int n)
    {
        int a[]=new int[n];
        for(int i=0;i<a.length;i++)
        {
            out("Enter A["+i+"]: ");
            a[i]=in().nextInt();
        }
        return a;
    }

    void showarray(int[] a)
    {
        for(int c:a)
            out("Array: " +c);
        out("\n");
    }

    void sortinc(int[] a,int n)
    {
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
                if(a[i]>a[j])
                {
                    int temp=a[i];
                    a[i]=a[j];
                    a[j]=temp;
                }
    }

    void sortdec(int[] a,int n)
    {
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
                if(a[i]<a[j])
                {
                    int temp=a[i];
                    a[i]=a[j];
                    a[j]=temp;
                }
    }

    int sum(int[] a,int n)
    {
        int s=0;
        for(int i=0;i<n;i++)
            s+=a[i];
        return s;
    }

    int search(int[] a,int n)
    {
        int s;
        out("Enter your value to search: ");
        s=in().nextInt();
        for(int i=0;i<n;i++)
        {
            if(s==a[i])
                s=a[i];
            else
                out("Search not found.");
        }
        return s;
    }

    public Array()
    {
        int n;
        out("Enter Value N: ");
        n=in().nextInt();
        int[] a=new int[n];
        a=getarray(n);
        showarray(a);
    }

    public static void main(String[] args)
    {   new Array();    }
}

Recommended Answers

All 2 Replies

Please edit your post with in 30 minutes and add code tags [code] YOUR CODE HERE [/code]
Secondly some problem description or any error messages would be beneficial (do not expect everyone to try copy&paste to run your application)

site the error code, and what is the goal of the program? don't let the readers to do the compilation

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.