title: In a for loop, is there a difference between pre/post-incrementing a loop control variable in terms of the total quantity of iterations?
body: <p>When I compile and run the code below with either <code>counter++</code> or <code>++counter</code> substituted for <code>x</code>, the output is identical; in both cases, numbers 1 - 10:</p>
  
  <pre><code>for (int counter = 1; counter &lt; 11; x)
  {
      std::cout &lt;&lt; counter &lt;&lt; endl;
  }
  </code></pre>
  
  <p>Originally I thought <code>++counter</code> would increment by 1 and then return the new value before for boolean expression in the loop header was evaluated. i.e when starting with <code>counter = 1</code> and using <code>++counter</code>, <code>counter</code> would have a value of 2 in the boolean expression. This appears to not be the case, as both outputs are identical rather than the <code>++counter</code> version having one less iteration, like I expected.</p>
  
  <p>Reading around, it appears <code>++counter</code> and <code>counter++</code> increment <code>counter</code> by 1 at either the start or end of the loop body respectively. In which case is this not, at least conceptually, an identical action? Because the end and the start of the loop are the same thing once the loop has past the first iteration. </p>
  
  <p>The only time I can see this making a difference is in the first iteration, where <code>std::cout &lt;&lt; counter &lt;&lt; endl;</code>should output 1 to the console if <code>counter++</code> is used (because 1 is added to counter at the end of the loop). Whilst <code>std::cout &lt;&lt; counter &lt;&lt; endl;</code> should output 2 to the console if <code>++counter</code> is used (because 1 is added to counter at the start of the loop). </p>
  
  <p>In addition to the question above, could you please precisely explain the order in which the three actions are evaluated in the for loop header, and explain exactly where the iterations occur when using <code>i++</code> and <code>++i</code>.</p>
  
  <p>Many thanks! </p>