fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int i,j,n,r,c;
  5. printf("enter no:");
  6. scanf("%d%d",&r,&c);
  7. int m1[r][c],m2[r][c],res[r][c];
  8. printf("elements of m1:");
  9. for(i=0;i<r;i++){
  10. for(j=0;j<c;j++){
  11. scanf("%d %d",&m1[i][j]);
  12. }
  13. }
  14. printf("elements of m2:");
  15. for(i=0;i<r;i++){
  16. for(j=0;j<c;j++){
  17. scanf("%d %d",&m2[i][j]);
  18. }
  19. }
  20. for(i=0;i<r;i++){
  21. for(j=0;j<c;j++){
  22. res[i][j]=m1[i][j]+m2[i][j];
  23. }
  24. }
  25. for(i=0;i<r;i++){
  26. for(j=0;j<c;j++){
  27. printf("%d%d",res[i][j]);
  28. }printf("\n");
  29. }
  30.  
  31. return 0;
  32. }
  33.  
  34.  
  35.  
Success #stdin #stdout 0.03s 25572KB
stdin
Standard input is empty
stdout
#include <stdio.h>

int main() {
    int i,j,n,r,c;
    printf("enter no:");
	scanf("%d%d",&r,&c);
    int m1[r][c],m2[r][c],res[r][c];
    printf("elements of m1:");
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            scanf("%d %d",&m1[i][j]);
        }
    }
    printf("elements of m2:");
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            scanf("%d %d",&m2[i][j]);
        }
    }
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            res[i][j]=m1[i][j]+m2[i][j];
        }
    }
    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            printf("%d%d",res[i][j]);
        }printf("\n");
    }
    
    return 0;
	}