the code is as follows plz tell me where i went wrong and if possible plz explain
Code:
#include<stdio.h>
main()
{
int a[10][10],b[10][10],c[10][10],i,j,m,n,p,q;
printf("input row and column of a matrix:\n");
scanf("%d%d",&m,&n);
printf("input row and column of the matrix:\n");
scanf("%d%d",&p,&q);
if((m==p)&&(n==q))
{
printf("matrices can be added\n");
printf("input A matrix:\n");
for(i=0;i<m;++i)
for(j=0;j<n;++j)
scanf("%d",&a[i][j]);
printf("input b matrix:\n");
for(i=0;i<m;++i)
for(j=0;j<n;++j)
scanf("%d",&a[i][j]);
for(i=0;i<m;++i)
{
for(j=0;j< n;++j)
c[i][j]=0;
c[i][j]=a[i][j]+b[i][j];
printf("%5d",c[i][j]);
printf("\n");
}
}
else
printf("matrices can not be added");
getch();
}
this code is getting executed but end results ie the sum is not as desired