title: Sum of each row and column in 2D array (C)
body: <p>I want to get the sum of each row and column of an array and print them one by one in C. I done half of work but I can't progress any more. There it is my code:    </p>
  
  <pre><code>int n,m;
  void sum_row_column(int array[n][m],int r,int c,int i,int j)
  {
  int sum_of_column1=0;
  int sum_of_row1;
  
  for(j=0,i=0;i&lt;r;i++)
  {
      sum_of_column1=sum_of_column1+array[i][j];
      if(i==r-1)
      {
          printf("\nSum of %d.column: %d\n",j+1,sum_of_column1);
          j=j+1;
      }
  }
  
  for(i=0,j=0;j&lt;r;j++)
  {
      sum_of_row1=sum_of_row1+array[i][j];
      if(j=c-1)
      {
          printf("\nSum of %d.row: %d\n",j+1,sum_of_row1);
          i=i+1;
      }
  }
  </code></pre>
  
  <p>As you can see it prints just first row's sum and column's sum. I thought if I add </p>
  
  <pre><code>i=0;
  </code></pre>
  
  <p>after</p>
  
  <pre><code>printf("\nSum of %d.column: %d\n",j+1,sum_of_column1);
  j=j+1
  </code></pre>
  
  <p>line, it can move second column and sum it too. But when I add </p>
  
  <pre><code>i=0;
  </code></pre>
  
  <p>the program go into infinite loop without any errors.
  This code is in the header but don't worry in the rest of the code there aren't any mistake.</p>