Previous Next
0 / 21
Module DEMO-32-109DEMO-C-32

Matrix Sum

DEMO-C-32 โ€ข Programming in C

Browser-only practice

Problem Statement

Matrix Sum

Write a program to calculate and print the sum of all elements in an N x M matrix.

Constraints

1 <= N, M <= 10. Integers within standard range.

Input Format

Input: Dimensions N M followed by the matrix elements.

Output Format

Output: The formatted result as specified.

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
2 2
25 48
23 31
127
Sum of 2x2 elements = 127.
Sample #2
Public sample
4 3
34 43 32
-2 39 49
42 6 10
-2 43 2
296
Sum of 4x3 elements = 296.
Sample #3
Public sample
5 4
47 7 7 10
17 8 6 8
5 7 -9 -2
32 7 -9 4
-5 28 28 10
206
Sum of 5x4 elements = 206.
Sample #4
Public sample
4 3
8 12 4
45 44 -7
33 50 42
6 -5 44
276
Sum of 4x3 elements = 276.

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings