Practice
2D Array Row Sums
HARDArrays
Read a 3×3 matrix of integers, entered row by row (9 values in total). For each row, output the sum of that row's three values, one sum per line.
Input: 9 integers in row-major order (3 values per row, 3 rows). Output: Three integers — the sum of row 1, row 2, and row 3.
Example:
Input: 1 2 3 (row 1)
4 5 6 (row 2)
7 8 9 (row 3)
Output: 6
15
24
(Enter all 9 values one per line)
Premium is coming soon. All grading features are currently unlocked.
Sample Test Cases
Test 1: 1–9 matrix
Inputs: 1, 2, 3, 4, 5, 6, 7, 8, 9
Expected: 6
15
24
Test 2: Mixed rows
Inputs: 10, 20, 30, 0, 0, 0, 5, 5, 5
Expected: 60
0
15
Test 3: Uniform rows
Inputs: 1, 1, 1, 2, 2, 2, 3, 3, 3
Expected: 3
6
9
Ctrl+Enter
Press Ctrl+Enter to run your code
or Ctrl+Shift+Enter to grade