Matrix addition in C can be easily implemented using two 2D arrays. To add two matrices using C program we first need to create two 2D arrays of the same Dimension because two matrices can only be added if both have same dimension i.e order.

So first we need to check if:

  • The number of rows of the matrix I = Number of rows of Matrix II.
  • The number of columns of Matrix I = Number of columns of Matrix II.

If the order is same then we proceed to take input in both the matrices. Then we add each of the element of the two matrices at same index and assign it as the element for the resultant Matrix using ‘for loop’.

Matrix Addition in C

Output for Matrix Addition C Program

When both matrices have the same dimension.

Matrix Addition in C

When the two matrices have a different dimension.

Matrix Addition C program

That’s all we require to write a C program for two matrix addition. If you have any doubt then do comment below.

Leave a Reply

Close Menu