title: Pre increment vs Post increment in array
body: <p>I am learning programming and I have started from C language. I was reading Let us C book. And I was going through this program in that book.</p>
  
  <pre><code>main( ) 
  { 
   int a[5] = { 5, 1, 15, 20, 25 } ; 
   int i, j, k = 1, m ; 
   i = ++a[1] ; 
   j = a[1]++ ; 
   m = a[i++] ; 
   printf ( "\n%d %d %d", i, j, m ) ; 
  }
  </code></pre>
  
  <p>My understanding was, it will print <code>i as 2</code>, <code>j as 1</code> and <code>m as 15</code></p>
  
  <p>But somehow it is printing as  <code>i as 3</code>, <code>j as 2</code> and <code>m as 15</code>? Why is it so?</p>
  
  <p>Below is my understanding-</p>
  
  <pre><code>b = x++;
  In this example suppose the value of variable ‘x’ is 5 then value of variable ‘b’ will be 5 because old value of ‘x’ is used.
  
  b = ++y;
  In this example suppose the value of variable ‘y’ is 5 then value of variable ‘b’ will be 6 because the value of ‘y’ gets modified before using it in a expression.
  </code></pre>
  
  <p>Is there anything wrong in my understanding?</p>