Addition of Two Matrix Program in C

Addition of Two Matrix Program

Here you will get example code with algorithm to make Addition of Two Matrix program in C.

Matrix addition in C involves adding corresponding elements of two matrices to create a new matrix. It’s done via nested loops that proceed in rows and columns, adding values element by element.

Addition of Two Matrix Program in C

Matrix Addition in C

We will take two matrices as input and displays their sum as output. This program also takes number of rows and columns in matrices as input. In this program variables r and c represents the number of rows and columns respectively.

Array variables x and y represents matrices to be added and z represents the resultant matrix.

For example

The sum of two matrices is given by

z[i][j] = x[i][j] + y[i][j]

in that i and j are row and column(index).

Algorithm for Addition of Two Matrix in C

Step 1: Enter the elements of the first matrix.

Step 2: Enter the elements of the second matrix.

Step 3: Display the elements of the first matrix.

Step 4: Display the elements of the second matrix.

Step 5: Add the elements of the both matrices.

Step 6: Display the sum of the both matrices.

Addition of Two Matrix Program in C

Input

Enter No of Rows & Columns (max : 5,5) :3 3

Enter Elements for 1st Matrix :

1 2 3

2 3 4

3  2 1

Enter Elements for 2nd Matrix :

2 3 4

5 6 3

4 5 6

Output

3 5 7

7 9 7

7 7 7

 

 

 

Check out our other C programming Examples

 

 

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top