title: C Programming: Initialize a 2D array of with numbers 1, 2, 3...etc
body: <p>I am having trouble creating a 2D Array of a size defined by the user, with numbers 1, 2, 3.etc.</p>
  
  <p>If the user chooses for example: <code>a = 2 and b = 2</code>, the program produces:</p>
  
  <pre><code>3 4
  
  3 4
  </code></pre>
  
  <p>instead of:</p>
  
  <pre><code>1  2
  
  3  4
  </code></pre>
  
  <p>My program looks like:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main()
  {
      int a = 0;
      int b = 0;
      int Array[a][b];
      int row, column;
      int count = 1;
  
  /*User Input */
      printf("enter a and b \n");
      scanf("%d %d", &amp;a, &amp;b);
  
  /* Create Array */
      for(row = 0; row &lt; a; row++)
      {
          for(column = 0; column &lt;b; column++)
          {
              Array[row][column] = count;
              count++;
          }
      }
  
  /* Print Array*/
      for(row = 0; row&lt;a; row++)
      {
          for(column = 0; column&lt;b; column++)
          {
              printf("%d ", Array[row][column]);
          }
          printf("\n");
      }
  
      return 0;
  }
  </code></pre>