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(); }
}
sotvisal -4 Newbie Poster
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.