Daryan997

Programming - practice

Oct 11th, 2020
908
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package javaapplication75;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class JavaApplication75 {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner input = new Scanner(System.in);
  9.         System.out.println("Enter your array size:");
  10.         int size = input.nextInt();
  11.         int ar[] = new int[size];
  12.         int sum = 0;
  13.         for (int i = 0; i < ar.length; i++) {
  14.             System.out.println("Enter number for index " + i);
  15.             ar[i] = input.nextInt();
  16.             sum += ar[i];
  17.         }
  18.         System.out.println("Sum of the array: " + sum);
  19.     }
  20. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×