Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
636 B
1
Indexable
Never
import java.util.Scanner;

public class OneDArray {
    public static void main(String[] args) {

        System.out.println("Enter the no of elements to be present in an array:");
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int arr[]=new int[n];

        System.out.println("Enter the array elements:");
        for(int i=0;i<arr.length;i++)
        {
            arr[i]=scanner.nextInt();

        }
        System.out.println("Entered array elements are");
        for(int i=0;i<arr.length;i++)
        {
            System.out.println(arr[i]);
        }

    }
}
Leave a Comment