Skip to content

Commit 0e9adfb

Browse files
committed
added arrays\Summing_Elements_In_Arrays.java
1 parent 23b0615 commit 0e9adfb

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package arrays;
2+
3+
public class Summing_Elements_In_Arrays {
4+
5+
public static void main(String[] args) {
6+
int array[]={21,134,223};
7+
int sum=0;
8+
9+
for(int x=0;x<array.length;x++) {
10+
sum+=array[x];
11+
}
12+
13+
/*
14+
* x is a value from 0-2, array = 3(elements)
15+
* the you add
16+
* sum + array[0]
17+
* + array[1]
18+
* + array[2]
19+
* to get the sum
20+
*/
21+
22+
23+
24+
25+
System.out.println("The sum of the numbers is " +sum);
26+
}
27+
28+
}

0 commit comments

Comments
 (0)