Sum of two Matrices is one of the operations performed on Matrices wherein Matrix A and Matrix B are are summed together resulting in a Matrix C which is the new Matrix formed by addition of A & B.
Language :C
[sourcecode language='c']
#include
void main()
{
int a[3][3], b[3][3], c[3][3],sum,i,j;
sum=0;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf(“Enter the values FOR %d row & %d column: “, i+1,j+1);
scanf(“%d”, &a[i][j]);
}
}
printf(“\n\n Matrix A\n”);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf(“\t %d”, a[i][j]);
}
printf(“\n”);
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf(“Enter the values FOR %d row & %d column: “, i+1,j+1);
scanf(“%d”, &b[i][j]);
}
}
printf(“\n\n Matrix B\n”);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf(“\t %d”, b[i][j]);
}
printf(“\n”);
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
c[i][j]=a[i][j]+b[i][j];
}
}
printf(“\n\n Sum of Matrix\n”);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf(“\t %d”, c[i][j]);
}
printf(“\n”);
}
}
[/sourcecode]







{ 4 comments… read them below or add one }
DevC say that problem is in &
@Felipe
Please note that the above Source Code has been updated, and will work. Thanks
DevC say that problem is in &
@Felipe
Please note that the above Source Code has been updated, and will work. Thanks