java program for creating an array and displaying its elements
import java.io.*;
import java.util.Scanner;
/**
*
* @author mithi
*/
public class Arrayelement {
public static void main(String[] args) {
int num,i;
System.out.println("Enter the limit of array");
Scanner sc=new Scanner(System.in);
num=sc.nextInt();
int array_name[]=new int [100];
System.out.println("Enter the element in the array one by one");
for(i=0;i<num;i++)
{
array_name[i]=sc.nextInt();
}
System.out.println("Entered array is ");
for(i=0;i<num;i++)
System.out.println(array_name[i]);
}
}
import java.util.Scanner;
/**
*
* @author mithi
*/
public class Arrayelement {
public static void main(String[] args) {
int num,i;
System.out.println("Enter the limit of array");
Scanner sc=new Scanner(System.in);
num=sc.nextInt();
int array_name[]=new int [100];
System.out.println("Enter the element in the array one by one");
for(i=0;i<num;i++)
{
array_name[i]=sc.nextInt();
}
System.out.println("Entered array is ");
for(i=0;i<num;i++)
System.out.println(array_name[i]);
}
}
out-
Enter the limit of array
5
Enter the element in the array one by one
45
12
89
32
78
Entered array is
45
12
89
32
78
BUILD SUCCESSFUL (total time: 12 seconds)
Comments
Post a Comment