fork download
  1. //Navya Agarwal
  2. #include <stdio.h>
  3.  
  4. int main() {
  5. int a[10][10], r,c,i,j;
  6. scanf("%d%d",&r,&c);
  7.  
  8. for(i=0;i<r;i++)
  9. for(j=0;j<c;j++)
  10. scanf("%d",&a[i][j]);
  11.  
  12. for(i=0;i<r;i++){
  13. int s=0;
  14. for(j=0;j<c;j++) s+=a[i][j];
  15. printf("Row %d=%d\n",i+1,s);
  16. }
  17.  
  18. for(j=0;j<c;j++){
  19. int s=0;
  20. for(i=0;i<r;i++) s+=a[i][j];
  21. printf("Col %d=%d\n",j+1,s);
  22. }
  23. }
  24.  
Success #stdin #stdout 0.01s 5320KB
stdin
2 2
1 2
3 4
stdout
Row 1=3
Row 2=7
Col 1=4
Col 2=6