# C Program For Matrix Addition

A matrix is a multi-dimensional array of elements.

C Program to create two matrices and add the corresponding elements of the two matrix together. This is known as matrix addition.

For matrix addition, the two matrix must be of the same order i.e number of rows and columns corresponding one matrix must be equal to the rows and columns of the other matrix.

```#include<stdio.h>
int main(){
int m,n,a[100][100],i,j,b[100][100];
printf("enter number of rows of first matrix ");
scanf("%d",&m);
printf("enter number of colomns of first matrix");
scanf("%d",&n);
for(i=0;i<m;i++)
for(j=0;j<n;j++){
printf("Enter Element at %d%d position of first matrix",i+1,j+1);
scanf("%d",&a[i][j]);

}
printf("\n \n");

printf("enter number of rows of second matrix ");
scanf("%d",&m);
printf("enter number of colomns of second matrix");
scanf("%d",&n);
for(i=0;i<m;i++)
for(j=0;j<n;j++){
printf("Enter Element at %d%d position of second matrix",i+1,j+1);
scanf("%d",&b[i][j]);

}
printf("\n \n");
for(i=0;i<m;i++){
for(j=0;j<n;j++){
printf(" %d ",a[i][j]+b[i][j]);
}
printf("\n");

}
return 0;
}

```

Output

Similarly, you can make a C Program to subtract two matrices. Try this program on your own and let me know in the comment section about any mistakes or difficulties in the program.