C Exercises: Find the sum of rows an columns of a Matrix
25. Sum of Rows & Columns
Write a program in C to find the sum of rows and columns of a matrix.
The task is to write a C program that computes the sum of rows and columns of a square matrix. The program prompts the user to input the size of the matrix and its elements, calculates the sum of each row and column, and displays the original matrix followed by the sums of its rows and columns as output.
Visual Presentation:

Sample Solution:
C Code:
Sample Output:
Find the sum of rows an columns of a Matrix: ------------------------------------------- Input the size of the square matrix : 2 Input elements in the first matrix : element - [0],[0] : 5 element - [0],[1] : 6 element - [1],[0] : 7 element - [1],[1] : 8 The matrix is : 5 6 7 8 The sum or rows and columns of the matrix is : 5 6 11 7 8 15 12 14
Flowchart:

For more Practice: Solve these Related Problems:
- Write a C program to compute the sum of each row and each column in a matrix and display them alongside the matrix.
- Write a C program to calculate the row and column sums of a matrix and then determine the overall total sum.
- Write a C program to compute and print the row-wise average and column-wise average of a matrix.
- Write a C program to calculate row and column sums using dynamic memory allocation for matrices.
C Programming Code Editor:
Previous: Write a program in C to find sum of left diagonals of a matrix.
Next: Write a program in C to print or display the lower triangular of a given matrix.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.