Paul Herring wrote:
>  
>
> On Mon, Oct 19, 2009 at 9:33 AM, Bilal Nawaz
> <[email protected] <mailto:bilalnawazhallian%40yahoo.com>> 
> wrote:
> > both these increments operator are same because of the following reasons
> > 1.i++ is postincrement operator means it increments the next value 
> of i after printing that value
> > for example
> > (for int i=0;i<10;i++)
> > {
> > cout<<i<<endl;
> > }
> > after printing zero it will make increment
> > whereas
> > (for int j=0;j<10;++j)
> > {
> > cout<<j<<endl;
> > }
> > it will make increment first then print values of j in the given range
>
> I suggest you run that through a compiler and then come back to 
> correct it.
>
> > regards
> > bilal nawaz
> >
> >
> >
> >
> > ________________________________
> > From: Asad Abbas <[email protected] 
> <mailto:cyberstudent99%40yahoo.com>>
> > To: c prog <[email protected] 
> <mailto:c-prog%40yahoogroups.com>>; c4swimmers ygroup 
> <[email protected] <mailto:C4Swimmers%40YahooGroups.Com>>
> > Sent: Sun, October 18, 2009 4:26:12 PM
> > Subject: [c-prog] for loop i++ and ++i ?
> >
> >
> > Why these both statements have same output??
> > why i++ and ++i works alike in for loop??
> >
> >
> > for(int i=0;i<5;i++)
> > or
> > for(int i=0;i<5;++i) ;
> >    cout << i << endl;
> >
> > //output:
> > /*
> > 0
> > 1
> > 2
> > 3
> > 4
> > */
> >
> > Thanx in Advance
> > Asad Abbas
> > UET Taxila
> > Pakistan---- --------- --------- --------- --------- --------- ---------
> >
> > One of the main causes of the fall of the Roman Empire was that, 
> lacking zero, they had no way to indicate successful termination of 
> their C programs.
> > Robert Firth
> >
> > [Non-text portions of this message have been removed]
> >
> >
> >
> >
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
> >
> >
> > ------------------------------------
> >
> > To unsubscribe, send a blank message to 
> <mailto:[email protected] 
> <mailto:c-prog-unsubscribe%40yahoogroups.com>>.Yahoo! Groups Links
> >
> >
> >
> >
>
> -- 
> PJH
>
> http://shabbleland.myminicity.com/ <http://shabbleland.myminicity.com/>
> http://www.chavgangs.com/register.php?referer=9375 
> <http://www.chavgangs.com/register.php?referer=9375>
> http://www.kongregate.com/?referrer=Shabble 
> <http://www.kongregate.com/?referrer=Shabble>
>
> 
They are both the same thing in the context he has used. Postfix or 
Prefix-increment/decrement work exactly the same when used in the 
for-loop's "update" expression. It is just like doing this:

int x = 0;
x++; // postfix, x now equals 1
x = 0;
++x; // prefix, x now equals 1

The only time it makes a difference is when it is used in another 
expression, for example (++x * 2) or (mystr[++x]), etc..


[Non-text portions of this message have been removed]

Reply via email to