array input from user in java
array input from user in java
import java.util.Scanner;
public class arr1 {
public static void main(String[] args) {
int size;
Scanner sc=new Scanner(System.in);
System.out.println("enter size of arry");
size=sc.nextInt();
int a[]=new int[size];
System.out.println("enter array elements");
for (int i=0;i<size;i++){
a[i]=sc.nextInt();
}
System.out.println("array is");
for (int i=0;i<size;i++){
System.out.println(a[i]);
}
}
}
Comments
Post a Comment