1. This program let you to add two matrices of same size and
displaying the elements of resultant matrix.
void main()
{
int a[2][2], b[2][2], c[2][2];
printf("enter the elements of matrix an");
for(i=0 ; i<=1 ; i++)
{
for(j=0 ; j<=1 ; j++)
{
scanf("%d",&a[i][j]);
}
}
printf("enter the elements of matrix bn");
for(i=0 ; i<=1 ; i++)
{
for(j=0 ; j<=1 ; j++)
{
scanf("%d",&b[i][j]);
}
}
printf("the sum of two matrices is n");
for(i=0 ; i<=1 ; i++)
{
for(j=0 ; j<=1 ; j++)
{
printf("%dn",a[i][j] + b[i][j]);
}
}
}
output
enter the elements of matrix a
1
2
3
4
enter the elements of matrix b