Below is the program to find the sum of two matrics in C language. You can edit it to your needs if you want to. I have taken two matrix with 3 X 2. You can change it.
The following code has been executed in Dev C++ and will also work with Ubuntu gcc.
Code:
#include<stdio.h>
void main(){
int a[3][2],b[3][2],c[3][2],i,j;
printf("Enter value for 1st matrix:\n");
for(i=0;i<3;i++){
for(j=0;j<2;j++){
scanf("%d",&a[i][j]);
}
}
printf("Enter the value for 2nd matrix:\n");
for(i=0;i<3;i++){
for(j=0;j<2;j++){
scanf("%d",&b[i][j]);
}
}
for(i=0;i<3;i++){
for(j=0;j<2;j++){
c[i][j]=a[i][j]+b[i][j];
}
}
printf("Sum of the 2 matrix is:\n");
for(i=0;i<3;i++){
for(j=0;j<2;j++){
printf("%d\t",c[i][j]); }
printf("\n");
}
}
