title: Difference between ++i and i++
body: <blockquote>
    <p><strong>Possible Duplicates:</strong> <br/>
    <a href="https://stackoverflow.com/questions/561588/what-is-more-efficient-i-or-i">What is more efficient i++ or ++i?</a> <br/>
    <a href="https://stackoverflow.com/questions/1525187/how-do-we-explain-the-result-of-the-expression-xxx">How do we explain the result of the expression (++x)+(++x)+(++x)?</a> <br/>
    <a href="https://stackoverflow.com/questions/484462/difference-between-i-and-i-in-a-loop">Difference between i++ and ++i in a loop?</a></p>
  </blockquote>
  
  <p>I am trying these two programs:</p>
  
  <pre><code>void fun(){
       int k = 0;
       int i= 10;
       k = (i++)+(++i);
       cout &lt;&lt; k &lt;&lt; endl;
  }
  </code></pre>
  
  <p>Output = 22 as i++ will give 10 and ++i will evaluate into 12.</p>
  
  <p>But</p>
  
  <pre><code>void fun(){
       int k = 0;
       int i = 10;
       k = (++i)+(++i);
       cout &lt;&lt; k &lt;&lt; endl;
  }
  </code></pre>
  
  <p>Output = 24</p>
  
  <p>It should be 23 I guess, or is there something that I am not able to see?</p>