C program to find sum of two matrices.
Solution:
This program finds the sum of two matrices. It can be done only if both the matrices are of same size. i.e the order of matrices is same like 2*2, 3*3, 4*4, 5*5 etc.

Output:

Solution:
This program finds the sum of two matrices. It can be done only if both the matrices are of same size. i.e the order of matrices is same like 2*2, 3*3, 4*4, 5*5 etc.

#include <stdio.h>
int main()
{
int a[4][4],b[4][4],s[4][4],i,j;
printf("Enter Elements of First 4*4 Matrix: \n\n");
for(i=0;i<=3;i++)
for(j=0;j<=3;j++)
{
scanf("%d",&a[i][j]);
}
printf("\nEnter Elements of Second 4*4 Matrix: \n\n");
for(i=0;i<=3;i++)
for(j=0;j<=3;j++)
{
scanf("%d",&b[i][j]);
}
for(i=0;i<=3;i++)
for(j=0;j<=3;j++)
{
s[i][j]=a[i][j]+b[i][j];
}
printf("\nSum of Matrices :\n\n");
for(i=0;i<=3;i++)
{
for(j=0;j<=3;j++)
{
printf("%d ",s[i][j]);
}
printf("\n");
}
return 0;
}
Output:



