The text below is selected, press Ctrl+C to copy to your clipboard. (⌘+C on Mac) No line numbers will be copied.
Guest
Abin
By Guest on 7th October 2024 08:00:30 AM | Syntax: PYTHON | Views: 67



New Paste New paste | Download Paste Download | Toggle Line Numbers Show/Hide line no. | Copy Paste Copy text to clipboard
  1. import java.io.*;
  2.         public class Arraydemo
  3.          {
  4.             public static void main(String[] args)
  5.              {
  6.                 try
  7.                   {
  8.                     DataInputStream in = new DataInputStream(System.in);
  9.                     System.out.println("Enter the no of elements in an array");
  10.                     int n = Integer.parseInt(in.readLine());
  11.                     int arr[] = new int[n];
  12.                     System.out.println("Enter the elements in an array");
  13.                     for (int i = 0; i < n; i++) {
  14.                     arr[i] = Integer.parseInt(in.readLine());
  15.                     }
  16.                System.out.println("The elements in an array are");
  17.                 for (int i = 0; i < n; i++)
  18.                   {
  19.                     System.out.println(arr[i]);
  20.                    }
  21.             }
  22.            
  23.             catch (Exception e) {
  24.             }
  25.        
  26.             }
  27. }





abin    





  • Recent Pastes