THINK FIRST·CODE LATER

← All labs

Row and column sums of a matrix

Problem

Write a class MatrixSums that reads two integers rows and cols, then rows × cols integers into a two-dimensional array, and prints the sum of each row and of each column:

Row 0: 6
Row 1: 15
Col 0: 5
Col 1: 7
Col 2: 9

The rows are printed first, in order, then the columns.

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.