fork download
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int a[3][3],b[3][3],c[3][3],i,j,m,n;
  5. printf("Enter the number of rows in the matrix:");
  6. scanf("%d\n",&i);
  7. printf("Enter the number of columns in the matrix:");
  8. scanf("%d\n",&j);
  9. printf("Enter the elements in the matrix A:");
  10. {
  11. for(i=0;i<m;i++)
  12. {
  13. for(j=0;j<n;j++)
  14. scanf("%d\n",&a[i][j]);
  15. }
  16. }
  17. printf("Enter the elements in the matrix B:");
  18. {
  19. for(i=0;i<m;i++)
  20. {
  21. for(j=0;j<n;j++)
  22. scanf("%d\n",&b[i][j]);
  23. }
  24. }
  25. {
  26. for(i=0;i<m;i++)
  27. {
  28. for(j=0;j<n;j++)
  29. printf("%d \n",c[i][j]=a[i][j]+b[i][j]);
  30. }
  31. }
  32. printf("The resultant matrix is:\n");
  33. {
  34. for(i=0;i<m;i++)
  35. {
  36. for(j=0;j<n;j++)
  37. scanf("%d\n",&c[i][j]);
  38. }
  39. }
  40. printf("\n");
  41. return 0;
  42. }
  43.  
Success #stdin #stdout 0.03s 25760KB
stdin
Standard input is empty
stdout
#include<stdio.h>
int main()
{
int a[3][3],b[3][3],c[3][3],i,j,m,n;
printf("Enter the number of rows in the matrix:");
scanf("%d\n",&i);
printf("Enter the number of columns in the matrix:");
scanf("%d\n",&j);
printf("Enter the elements in the matrix A:");
{
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
scanf("%d\n",&a[i][j]);
}
}
printf("Enter the elements in the matrix B:");
{
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
scanf("%d\n",&b[i][j]);
}
}
{
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
printf("%d \n",c[i][j]=a[i][j]+b[i][j]);
}
}
printf("The resultant matrix is:\n");
{
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
scanf("%d\n",&c[i][j]);
}
}
printf("\n");
return 0;
}