fork download
  1. //Q73. Find the sum of each row of a matrix and store it in an array.
  2. #include <stdio.h>
  3. int main() {
  4. int r,c,a[10][10],i,j,rowSum[10]={0};
  5. scanf("%d%d",&r,&c);
  6. for(i=0;i<r;i++)
  7. for(j=0;j<c;j++){
  8. scanf("%d",&a[i][j]);
  9. rowSum[i]+=a[i][j];
  10. }
  11. for(i=0;i<r;i++)
  12. printf("%d ",rowSum[i]);
  13. }
  14.  
Success #stdin #stdout 0s 5320KB
stdin
2 3 
1 2 3
4 5 6
stdout
6 15