We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5f5d022 commit 3e53d42Copy full SHA for 3e53d42
ArraySum.java
@@ -0,0 +1,19 @@
1
+import java.util.Scanner;
2
+import java.util.Arrays;
3
+public class ArraySum{
4
+ public static void main(String[] args) {
5
+ Scanner sc= new Scanner(System.in);
6
+ System.out.println("Enter the size of array: ");
7
+ int size= sc.nextInt();
8
+ int[] numbers= new int[size];
9
+ System.out.println("Enter "+size+"numbers");
10
+ for (int i =0; i<size; i++) numbers[i]= sc.nextInt();
11
+ System.out.println("enter array element: "+Arrays.toString(numbers));
12
+ int sum=0;
13
+ for (int num:numbers)sum+=num;
14
+ System.out.println("Sum of array elements:" +sum);
15
+ sc.close();
16
+
17
+ }
18
19
+}
0 commit comments