title: Finding Number of Element of Each Column in 2-d Array
body: <p>I try to make C program but get problem.
  The program is finding number of elements in each column.</p>
  <p>Input :</p>
  <pre><code>4 4
  </code></pre>
  <p>Matrix:</p>
  <pre><code>1 0 1 1
  0 0 0 0
  0 0 0 1
  1 1 1 1
  </code></pre>
  <p>Output should be the number of 1's in columns</p>
  <p>Output :</p>
  <pre><code>2 1 2 3
  </code></pre>
  <p>This my program but it does not work properly:</p>
  <pre><code>#include&lt;stdio.h&gt;
  
  int main()
  {
      int i , j, r , c , n , a[100][100],max[100];
      printf(&quot;Enter the number of rows: &quot;);
      scanf(&quot;%d&quot;,&amp;r);
      printf(&quot;Enter the number of columns: &quot;);
      scanf(&quot;%d&quot;,&amp;c);
      printf(&quot;Enter the elements of the array- \n&quot;);
  
      printf(&quot;The input matrix is:- \n&quot;);
      for(i = 0; i &lt; r; i++)
      {
          for(j = 0; j &lt; c; j++)
          {
              printf(&quot;%d\t&quot;,a[i][j]);
          }
          printf(&quot;\n&quot;);
      }
      for(i = 0; i &lt; r; i++)
      {
          max[i] = a[i][j];
          for(j = 0; j &lt; c ; j++)
          {
              if(a[i][j]&gt;max[i])
              {
                  max[i]=a[i][j];
              }
          }
      }
      for(i = 0; i &lt; r; i++)
      {
          printf(&quot;the element of the row %d is: %d\n&quot;,i,max[i]);
      }
  }
  </code></pre>
  <p>I need help for fixed the program. Thank you :)</p>