C Program to Find Sum of each and every Row and Column in a Matrix

In this tutorial you will learn about the C Program to Find Sum of each and every Row and Column in a Matrix and its application with practical example.

C Program to Find Sum of each and every Row and Column in a Matrix

In this tutorial, we will learn to create a C program that will Find the Sum of each row and column in a Matrix using C programming.

Prerequisites

Before starting with the tutorial, we assume that you are the best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • For loop in C programming.

Algorithm:-

Program to find the Sum of each and every Row and Column in a Matrix:-

In this tutorial, we will find the Sum of each row and every column in a Matrix. First, we will take the size of the matrix from the user, and then we will take the input elements of the matrices. Now we will use the for loop to add the values of rows of that matrix, as well as adding the elements of the columns. At last, we will print the result matrix row and the column values after adding.

Below is a C program to find the sum of each row and every column in a matrix.

Program:-

 

Output:-

In the above program, we have first initialized the required variable.

  • a[10][10]= it will hold the integer value.
  • rw = it will hold the integer value for the loop.
  • cl = it will hold the integer value for the loop.
  • row = it will hold the input integer value for rows.
  • Column = it will hold the input integer value for columns.

Taking the size and the elements of the matrix from the user.

Calculating the Sum of each ROW and every COLUMN in the matrix using a for loop.

Printing the Sum of each Row in a matrix.

Printing the Sum of every Column in a column.

In this tutorial we have learn about the C Program to Find Sum of each and every Row and Column in a Matrix and its application with practical example. I hope you will like this tutorial.