#include<stdio.h>
int
main()
{
int
c[100][100],a[50][50],b[50][50],an,am,bn,bm,i,j;
printf
(
"Enter a number of row and collum of a"
);
scanf
(
"%d%d"
,&an,&am);
printf
(
"Enter a number of row and collum of b"
);
scanf
(
"%d%d"
,&bn,&bm);
printf
(
"Enter matrix a \n"
);
for
(i=0;i<an;i++)
{
for
(j=0;j<am;j++)
{
scanf
(
"%d"
,&a[i][j]);
}
}
printf
(
"enter matrix b \n"
);
for
(i=0;i<bn;i++)
{
for
(j=0;j<bm;j++)
{
scanf
(
"%d"
,&b[i][j]);
}
}
if
((an!=bn)||(am!=bm))
{
printf
(
"sum cannot be done /n"
);
}
else
{
for
(i=0;i<an;i++)
{
for
(j=0;j<am;j++)
{
c[i][j]=a[i][j]+b[i][j];
}
}
printf
(
"matrix a is \n"
);
for
(i=0;i<an;i++)
{
for
(j=0;j<am;j++)
{
printf
(
" %d "
, a[i][j] );
}
printf
(
"\n"
);
}
printf
(
"matrix b is \n"
);
for
(i=0;i<an;i++)
{
for
(j=0;j<am;j++)
{
printf
(
" %d "
, b[i][j] );
}
printf
(
"\n"
);
}
printf
(
"sum of a and b is \n"
);
for
(i=0;i<an;i++)
{
for
(j=0;j<am;j++)
{
printf
(
" %d "
, c[i][j] );
}
printf
(
"\n"
);
}
}
return
0;
}