#include<stdio.h>
#include<conio.h>
main()
{
int r,c;
int a[3][3];
int b[3][3];
int d[3][3];
int e[3][3];
//matrices A................................
for(r=0;r<3;r++)
{
for(c=0;c<3;c++)
{
printf("Enter the number at A[%d,%d]: ",r,c);
scanf("%d",&a[r][c]);
}
} //outer loop
//matrices B................................
for(r=0;r<3;r++)
{
for(c=0;c<3;c++)
{
printf("Enter the number at B[%d,%d]: ",r,c);
scanf("%d",&b[r][c]);
}
} //outer loop
//sum of these matrices.............................
for(r=0;r<3;r++)
{
for(c=0;c<3;c++)
{
d[r][c]=a[r][c] +b[r][c];
}
} //outer loop
for(r=0;r<3;r++)
{
for(c=0;c<3;c++)
{
e[r][c]=a[r][c]-b[r][c];
}
} //outer loop
//printing the A.......................
printf("\n\n\nMatrices A: \n");
for(r=0;r<3;r++)
{
printf("|\t");
for(c=0;c<3;c++)
{
printf("%d\t",a[r][c]);
}
printf("|\n");
} //outer loop
//printing the A.......................
printf("\n\n\nMatrices B: \n");
for(r=0;r<3;r++)
{
printf("|\t");
for(c=0;c<3;c++)
{
printf("%d\t",b[r][c]);
}
printf("|\n");
} //outer loop
//printing the sum.......................
printf("\n\n\nMatrices D: (Sum of A & B)\n");
for(r=0;r<3;r++)
{
printf("|\t");
for(c=0;c<3;c++)
{
printf("%d\t",d[r][c]);
}
printf("|\n");
} //outer loop
//printing the sum.......................
printf("\n\n\nMatrices E: (Difference of A & B)\n");
for(r=0;r<3;r++)
{
printf("|\t");
for(c=0;c<3;c++)
{
printf("%d\t",e[r][c]);
}
printf("|\n");
} //outer loop
}