← Arrays & Pointer Arithmetic

Grid Row Sums

medium

Read a rows x cols grid of integers (already read into grid for you), and print the sum of each row, one sum per line.

This is the standard “visit every element of a 2D array” nested loop from the lesson, with one twist: the sum has to reset at the start of every row, not accumulate across the whole grid. Declare sum fresh inside the outer loop, not before it – if you declare it once outside both loops, you’ll get one running total for the entire grid instead of one total per row.

Your solution

"Run" uses the sample stdin ("2 3\n1 2 3\n4 5 6"). "Submit" checks your code against all 3 test cases.

Test results

Submit your solution to run it against all test cases.

Hints

    Reference solution