Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaapplication75;
- import java.util.Scanner;
- public class JavaApplication75 {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- System.out.println("Enter your array size:");
- int size = input.nextInt();
- int ar[] = new int[size];
- int sum = 0;
- for (int i = 0; i < ar.length; i++) {
- System.out.println("Enter number for index " + i);
- ar[i] = input.nextInt();
- sum += ar[i];
- }
- System.out.println("Sum of the array: " + sum);
- }
- }
Add Comment
Please, Sign In to add comment