Below is the program in the C programming language to add two matrices and store the result in the third matrix –
/* C program to perform addition on two matrices */ #include<stdio.h> #include<conio.h> void main() { int i,j,ar1[100][100],ar2[100][100],ar3[100][100],m,n; printf("Enter values of m and n to set order m x n of both the matrices"); scanf("%d %d",&n,&m); printf("Enter elements of 1st matrix"); for(i=0;i<n;i++) { for(j=0;j<m;j++) { scanf("%d",&ar1[i][j]); } } printf("Enter elements of 2nd matrix"); for(i=0;i<n;i++) { for(j=0;j<m;j++) { scanf("%d",&ar2[i][j]); } } printf("Matrix after addition of two matrices is -- \n"); for(i=0;i<n;i++) { for(j=0;j<m;j++) { ar3[i][j]=ar1[i][j]+ar2[i][j]; printf("%d\t",ar3[i][j]); } printf("\n"); } getch(); }