Skip to content

Commit ad3408d

Browse files
committed
feat: Calculate sum of all elements in the array including negatives
🧠 Logic: - Initialize `sum` to 0. - Use enhanced for loop (`for-each`) to iterate over all elements in the array. - Accumulate each value in `sum`, regardless of whether it’s positive or negative. - Print the final computed sum. Signed-off-by: Somesh diwan <[email protected]>
1 parent b40a34b commit ad3408d

File tree

1 file changed

+0
-1
lines changed

1 file changed

+0
-1
lines changed

Section9ArrayAB/Array 2.0/src/SumOfArray.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ public static void main(String[] args) {
77
sum+=i;
88
}
99
System.out.println(sum);
10-
1110
/*
1211
for (int i=0; i<arr.length;i++) {
1312
sum+=arr[i];

0 commit comments

Comments
 (0)