Behavior of post increment in cout
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/2902638/post-and-pre-increment-in-c">post and pre increment in c</a>  </p>
</blockquote>



<pre><code>#include &lt;iostream&gt;
using namespace std;

main(){

int i = 5;

cout &lt;&lt; i++ &lt;&lt; i--&lt;&lt; ++i &lt;&lt; --i &lt;&lt; i &lt;&lt; endl;


}
</code></pre>

<p>The above program compiled with g++ gives output :</p>

<pre><code>45555
</code></pre>

<p>While the following program:</p>

<pre><code>int x=20,y=35;

x =y++ + y + x++ + y++;

cout &lt;&lt; x&lt;&lt; endl &lt;&lt; y;
</code></pre>

<p>gives result as </p>

<pre><code>126

37
</code></pre>

<p>Can anyone please explain the output.</p>
