**The addition of matrix in c** is to add two matrices programmatically.

**What is the matrix:** It is a collection of numbers arranged in rows and columns.

Matrix representation

Matrices are stored in the multidimensional array in c which is stored in rows and column format.

**How to add two matrices**

Addition of matrix in c: First we take two matrices with specific rows and columns. Then we add a pair of entries by row index and column index. And store in the third matrix. Print addition of matrices.

**Note**:- we can’t add matrices with different sizes.

**Matrix addition example**

## Algorithm addition of matrix in c

- Declare variable
- Take two matrices input
- Add matrices by adding it’s pair
- Print addition of matrices

## Program for addition of matrix in c

#include<stdio.h> main() { int i,j,rows,col; printf("Enter number of rows\n"); scanf("%d",&rows); printf("Enter number of columns\n"); scanf("%d",&col); int a1[rows][col],a2[rows][col],add[rows][col]; //Taking input for 1st matrix printf("Enter Matrix 1\n"); for(i=0;i<rows;i++) { for(j=0;j<col;j++) { scanf("%d",&a1[i][j]); } } //Taking input for 2nd matrix printf("Enter Matrix 2\n"); for(i=0;i<rows;i++) { for(j=0;j<col;j++) { scanf("%d",&a2[i][j]); } } //Addition of matrix for(i=0;i<rows;i++) { for(j=0;j<col;j++) { add[i][j]=a1[i][j]+a2[i][j]; } } printf("Addition of above matrices is\n"); for(i=0;i<rows;i++) { for(j=0;j<col;j++) { printf("%d\t",add[i][j]); } printf("\n"); } }

**Output :**