<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: 3.3 &#8212; Increment/decrement operators, and side effects</title>
	<atom:link href="http://www.learncpp.com/cpp-tutorial/33-incrementdecrement-operators-and-side-effects/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.learncpp.com/cpp-tutorial/33-incrementdecrement-operators-and-side-effects/</link>
	<description></description>
	<lastBuildDate>Tue, 07 Feb 2012 12:30:29 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: zingmars</title>
		<link>http://www.learncpp.com/cpp-tutorial/33-incrementdecrement-operators-and-side-effects/comment-page-1/#comment-96113</link>
		<dc:creator>zingmars</dc:creator>
		<pubDate>Sat, 08 Oct 2011 12:38:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/33-incrementdecrement-operators-and-side-effects/#comment-96113</guid>
		<description>printf for some reason seems to evaluate the i++ once it&#039;s done, so it&#039;s 3 (you incremented it before using it - ++i) * 3 * 4.
the second case (n=) simply evaluates the i++, and since the other additions are done only after the statement is done, you get 3*3*3
the first case is the same as the second one, except it adds +2 gained from the increments (i++) before.</description>
		<content:encoded><![CDATA[<p>printf for some reason seems to evaluate the i++ once it&#8217;s done, so it&#8217;s 3 (you incremented it before using it &#8211; ++i) * 3 * 4.<br />
the second case (n=) simply evaluates the i++, and since the other additions are done only after the statement is done, you get 3*3*3<br />
the first case is the same as the second one, except it adds +2 gained from the increments (i++) before.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nagaraj</title>
		<link>http://www.learncpp.com/cpp-tutorial/33-incrementdecrement-operators-and-side-effects/comment-page-1/#comment-96090</link>
		<dc:creator>nagaraj</dc:creator>
		<pubDate>Wed, 05 Oct 2011 08:47:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/33-incrementdecrement-operators-and-side-effects/#comment-96090</guid>
		<description>Hi all
int i=2;
i=++i * i++ * i++; answer i am geeting is 29
n=++i*i++*i++; answer i am getting is 27
printf(“%d”,++i*i++*i++); answer i am getting is 36
 for same expression getting different values..please sort this problem

how complier is going evalute? please reply me…</description>
		<content:encoded><![CDATA[<p>Hi all<br />
int i=2;<br />
i=++i * i++ * i++; answer i am geeting is 29<br />
n=++i*i++*i++; answer i am getting is 27<br />
printf(“%d”,++i*i++*i++); answer i am getting is 36<br />
 for same expression getting different values..please sort this problem</p>
<p>how complier is going evalute? please reply me…</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nagaraj</title>
		<link>http://www.learncpp.com/cpp-tutorial/33-incrementdecrement-operators-and-side-effects/comment-page-1/#comment-96089</link>
		<dc:creator>nagaraj</dc:creator>
		<pubDate>Wed, 05 Oct 2011 08:26:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/33-incrementdecrement-operators-and-side-effects/#comment-96089</guid>
		<description>Hi all
int i=2;
i=++i * i++ * i++; answer i am geeting is 29
n=++i+i++*i++; answer i am getting is 27
printf(&quot;%d&quot;,++i+i++*i++); answer i am getting is 36

how complier is going evalute? please reply me...</description>
		<content:encoded><![CDATA[<p>Hi all<br />
int i=2;<br />
i=++i * i++ * i++; answer i am geeting is 29<br />
n=++i+i++*i++; answer i am getting is 27<br />
printf(&#8220;%d&#8221;,++i+i++*i++); answer i am getting is 36</p>
<p>how complier is going evalute? please reply me&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zingmars</title>
		<link>http://www.learncpp.com/cpp-tutorial/33-incrementdecrement-operators-and-side-effects/comment-page-1/#comment-95995</link>
		<dc:creator>zingmars</dc:creator>
		<pubDate>Sat, 10 Sep 2011 09:16:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/33-incrementdecrement-operators-and-side-effects/#comment-95995</guid>
		<description>It really depends on what you wanted to achieve in the first place.</description>
		<content:encoded><![CDATA[<p>It really depends on what you wanted to achieve in the first place.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: quynhntn</title>
		<link>http://www.learncpp.com/cpp-tutorial/33-incrementdecrement-operators-and-side-effects/comment-page-1/#comment-95988</link>
		<dc:creator>quynhntn</dc:creator>
		<pubDate>Wed, 07 Sep 2011 04:14:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/33-incrementdecrement-operators-and-side-effects/#comment-95988</guid>
		<description>Fix me if i&#039;m wrong n sorry about my bad english.
Don&#039;t apply increment\decrement twice to the same variable.
it make somthing ambiguous in C++
U can use a temp variable.
Ex: i=i++*i++*++i*++i;
int i = 1;
int a = i++; ( a= 1, i = 2)
a = a * (i++); ( a=2, i = 3)
a = a * (++i); ( i =4, a = 2*4=8, )
a = a * (++i); ( i = 5, a = 8*5=40 )</description>
		<content:encoded><![CDATA[<p>Fix me if i&#8217;m wrong n sorry about my bad english.<br />
Don&#8217;t apply increment\decrement twice to the same variable.<br />
it make somthing ambiguous in C++<br />
U can use a temp variable.<br />
Ex: i=i++*i++*++i*++i;<br />
int i = 1;<br />
int a = i++; ( a= 1, i = 2)<br />
a = a * (i++); ( a=2, i = 3)<br />
a = a * (++i); ( i =4, a = 2*4=8, )<br />
a = a * (++i); ( i = 5, a = 8*5=40 )</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zingmars</title>
		<link>http://www.learncpp.com/cpp-tutorial/33-incrementdecrement-operators-and-side-effects/comment-page-1/#comment-95553</link>
		<dc:creator>zingmars</dc:creator>
		<pubDate>Mon, 13 Jun 2011 19:52:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/33-incrementdecrement-operators-and-side-effects/#comment-95553</guid>
		<description>Wait, where&#039;s the problem? Your post isn&#039;t really specifying a problem.</description>
		<content:encoded><![CDATA[<p>Wait, where&#8217;s the problem? Your post isn&#8217;t really specifying a problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: saurabh verma</title>
		<link>http://www.learncpp.com/cpp-tutorial/33-incrementdecrement-operators-and-side-effects/comment-page-1/#comment-95545</link>
		<dc:creator>saurabh verma</dc:creator>
		<pubDate>Thu, 09 Jun 2011 19:43:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/33-incrementdecrement-operators-and-side-effects/#comment-95545</guid>
		<description>i am facing lots of problem pls sort it out
       i= - --i-i-- - --i;
       i= ++i*++i*i++*++i;
        i=++i*++i*i++;
      i=i++*i++*++i*++i;
      i=i++*++i*++i;
      i=++i*++i*++i; 
plz sort this problem
i am using gcc compiler...  
plz reply soon</description>
		<content:encoded><![CDATA[<p>i am facing lots of problem pls sort it out<br />
       i= &#8211; &#8211;i-i&#8211; &#8211; &#8211;i;<br />
       i= ++i*++i*i++*++i;<br />
        i=++i*++i*i++;<br />
      i=i++*i++*++i*++i;<br />
      i=i++*++i*++i;<br />
      i=++i*++i*++i;<br />
plz sort this problem<br />
i am using gcc compiler&#8230;<br />
plz reply soon</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: saurabh verma</title>
		<link>http://www.learncpp.com/cpp-tutorial/33-incrementdecrement-operators-and-side-effects/comment-page-1/#comment-95544</link>
		<dc:creator>saurabh verma</dc:creator>
		<pubDate>Thu, 09 Jun 2011 19:32:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/33-incrementdecrement-operators-and-side-effects/#comment-95544</guid>
		<description>boss actually whatever you have expalined i am getting that is for turbo c but still i am facing lots of problem pls sort it out
       i= - --i-i-- - --i;
       i= ++i*++i*i++*++i;
        i=++i*++i*i++;
      i=i++*i++*++i*++i;
      i=i++*++i*++i;
      i=++i*++i*++i; 
plz sort this problem
i am using gcc compiler...  
plz reply soon</description>
		<content:encoded><![CDATA[<p>boss actually whatever you have expalined i am getting that is for turbo c but still i am facing lots of problem pls sort it out<br />
       i= &#8211; &#8211;i-i&#8211; &#8211; &#8211;i;<br />
       i= ++i*++i*i++*++i;<br />
        i=++i*++i*i++;<br />
      i=i++*i++*++i*++i;<br />
      i=i++*++i*++i;<br />
      i=++i*++i*++i;<br />
plz sort this problem<br />
i am using gcc compiler&#8230;<br />
plz reply soon</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zingmars</title>
		<link>http://www.learncpp.com/cpp-tutorial/33-incrementdecrement-operators-and-side-effects/comment-page-1/#comment-95541</link>
		<dc:creator>zingmars</dc:creator>
		<pubDate>Thu, 09 Jun 2011 15:18:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/33-incrementdecrement-operators-and-side-effects/#comment-95541</guid>
		<description>I suspect that your compiler is being weird, because mine (VC++) outputs 14 in both cases (which it should).</description>
		<content:encoded><![CDATA[<p>I suspect that your compiler is being weird, because mine (VC++) outputs 14 in both cases (which it should).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: zingmars</title>
		<link>http://www.learncpp.com/cpp-tutorial/33-incrementdecrement-operators-and-side-effects/comment-page-1/#comment-95540</link>
		<dc:creator>zingmars</dc:creator>
		<pubDate>Thu, 09 Jun 2011 15:14:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/33-incrementdecrement-operators-and-side-effects/#comment-95540</guid>
		<description>It&#039;s as technorat said.
consider this expression - x = (a++) + (a++);
now what happens is it takes the value of a, adds the value of a to it, and then does the incrementing (if a - 5, then x will be 10, and a will be 7 in the end).
It&#039;s the same thing when having ++ in front.
example x = (++a) + (++a);
It takes a value, increments it, then it sees another ++ in the statement, so it increments &#039;a&#039; again, and then it does the adding, meaning that if a was 5, then x will be 14, and a will be 7 in the end.
Also - you don&#039;t really need the brackets in this case, as ++ has higher priority than the standard + sign (tho it helps the readability).</description>
		<content:encoded><![CDATA[<p>It&#8217;s as technorat said.<br />
consider this expression &#8211; x = (a++) + (a++);<br />
now what happens is it takes the value of a, adds the value of a to it, and then does the incrementing (if a &#8211; 5, then x will be 10, and a will be 7 in the end).<br />
It&#8217;s the same thing when having ++ in front.<br />
example x = (++a) + (++a);<br />
It takes a value, increments it, then it sees another ++ in the statement, so it increments &#8216;a&#8217; again, and then it does the adding, meaning that if a was 5, then x will be 14, and a will be 7 in the end.<br />
Also &#8211; you don&#8217;t really need the brackets in this case, as ++ has higher priority than the standard + sign (tho it helps the readability).</p>
]]></content:encoded>
	</item>
</channel>
</rss>

