>From: ~Rick <[email protected]> >To: "[email protected]" <[email protected]> >X-Mailer: iPhone Mail (7D11) >Subject: Re: [c4swimmers.net] Where am I Wrong? >Date: Sat, 5 Dec 2009 10:28:15 -0500 > > > >On Dec 3, 2009, at 8:33, Asad Abbas ><<mailto:[email protected]>[email protected]> wrote: > >> >> >>Consider the following code >> >> main() >> { >> for(int i=1,m=9;++i<4;) >> for(int j=1;j<4;j++) >> for (int k=1;k++<4;) >> cout<<(i==3?++m+1:m--); >> getch(); >> } >> >>Its output: (on Dev C++) >> >>9876543212345678910 >> >>--- >> >>I could not understand when 'i' is not equal to 3 'm--' is executed >>so value of m is decremented by '1' (thats right) >>But when i==3 and ++m+1 is executed then why the value of m is >>incremented by 1 only? >>(++m+1) This should increment the value of m by 2 :( >> >>--- >> >>Where am i Wrong? >> >>Thanx in advance! >> >>Regards! >>Asad Abbas >>Pakistan >>--- >Hi, > >You aren't adding 2 to m. You are incrementing m by 1 then printing >a value of m + 1. You could try using > >cout<<(i==3?(m+=2):m--); > >~Rick > >Sent from my iPhone
You asked this last week on another group and I answered it. ~Rick [Non-text portions of this message have been removed]
