source code:
#include "stdafx.h"
/* display sum of two matrix*/
int _tmain(int argc, _TCHAR* argv[])
{
int a[3][3], b[3][3], c[3][3], i, j;
i = j = 0;
printf("input elements into the first matrix a[3][3]\n");
for (i = 0; i < 3; i++)
{
for(j = 0; j < 3; j++)
{
scanf_s("%d", &a[i][j]);
}
}
printf("input elements into the first matrix b[3][3]\n");
for (i = 0; i < 3; i++)
{
for(j = 0; j < 3; j++)
{
scanf_s("%d", &b[i][j]);
}
}
for (i = 0; i < 3; i++)
{
for(j = 0; j < 3; j++)
{
c[i][j] = a[i][j]+b[i][j];
}
}
printf("the sum of the two matrix is below:\n");
for (i = 0; i < 3; i++)
{
for(j=0;j<3;j++)
{
printf("%d ",c[i][j]);
}
printf("\n");
}
getchar();
}
inputs and outputs:
![](https://img-blog.csdn.net/20140604145847046?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaGFpeWFuMjAxNA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)