title: 2D array print out sum of elements
body: <p>I writing a program that sum of elements in a 2D array and print out the sum.</p>
  
  <p>Here my code so far:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;stdio.h&gt;
  
  int main()
  {
      int array [3][5] = 
      {
          { 1, 2, 3, 4, 5, }, // row 0
          { 6, 7, 8, 9, 10, }, // row 1
          { 11, 12, 13, 14, 15 } // row 2
      };
  
      int i, j=0;
      int num_elements=0;
      float sum=0;
  
      for (i=0; i&lt;num_elements; i++)
      {
          sum = sum + array[i][j];
  
      }
  
  /*for(i=0; i&lt;num_elements; i++)
     {
       printf("%d ", array[i][j]);
     }*/
  
      // printf("a[%d][%d] = %d\n", sum);
  
      // output each array element's value 
      for ( i = 0; i &lt; 3; i++ )
      {
        for ( j = 0; j &lt; 5; j++ )
        {
            printf("a[%d][%d] = %d\n", i,j, array[i][j]);
  
        }
      }
  
      system("PAUSE");
      return 0;
  }
  </code></pre>
  
  <p>I can print out the elements in each array fine. But I want to print out the sum of elements. I tried one as you can see in the comment section but it didn't work. Can anyone help?</p>