The text below is selected, press Ctrl+C to copy to your clipboard. (⌘+C on Mac) No line numbers will be copied.
Guest
New
By Guest on 7th October 2024 07:50:03 AM | Syntax: PYTHON | Views: 62



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.  
  3. class InitArray {
  4.     public static void main(String args[]) {
  5.         try {
  6.             int n;
  7.             int a[] = new int[20];
  8.  
  9.             BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
  10.  
  11.             System.out.println("Enter the Array Limit:");
  12.             n = Integer.parseInt(in.readLine());
  13.  
  14.             System.out.println("Enter the Array elements:");
  15.             for (int i = 0; i < n; i++) {
  16.                 a[i] = Integer.parseInt(in.readLine());
  17.             }
  18.  
  19.             System.out.println("Array elements:");
  20.             for (int i = 0; i < n; i++) {
  21.                 System.out.println(a[i]);
  22.             }
  23.         } catch (Exception e) {
  24.             System.out.println("An error occurred: " + e.getMessage());
  25.         }
  26.     }
  27. }





new    





  • Recent Pastes