title: Array - Last index
body: <p>In an array, the index of the first element is zero. So an array declared as:</p>
  
  <pre><code>int a[5];
  </code></pre>
  
  <p>should have a[4] as the last element. However, when I execute the following code:</p>
  
  <pre><code>int n;
  cin&gt;&gt;n;
  int a[n];
  for(int i = 0; i++&lt;n; cin&gt;&gt;a[i]);
  for(int i = 0; i++&lt;n; cout&lt;&lt;i&lt;&lt;" "&lt;&lt;a[i]&lt;&lt;endl);
  </code></pre>
  
  <p>And give the input as:</p>
  
  <pre><code>5 1 2 3 4 5
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>1 1
  2 2
  3 3
  4 4
  5 5
  </code></pre>
  
  <p>That implies that a[5] = 5. I was wondering as to how that is possible. Shouldn't it display some garbage value instead?</p>