Skip to content

Commit f52f170

Browse files
committed
feat: Add two integer arrays element-wise and display the result
🧠 Logic: - Reads 5 elements each into arrays A and B using Scanner. - Adds corresponding elements from A and B, stores result in array C. - Iterates over array C to print the sum of A and B element-wise. Signed-off-by: Somesh diwan <[email protected]>
1 parent c4adfc6 commit f52f170

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

Section9ArrayAB/Array IMP/ArrayAdd.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ public static void main(String[] args) {
1717
B[i] = sc.nextInt();
1818
}
1919

20-
// Add arrays A and B, store result in C
20+
// Add arrays A and B, store a result in c.
2121
for (int i = 0; i < A.length; i++) {
2222
C[i] = A[i] + B[i];
2323
}
2424

25-
// Print result
2625
System.out.println("Sum of arrays:");
2726
for (int i = 0; i < C.length; i++) {
2827
System.out.print(C[i] + " ");

0 commit comments

Comments
 (0)