Re: [algogeeks] post and pre increment operators

2011-01-09 Thread juver++
You are wrong, this doesn't depend on the order which is used by printf. In C/C++ order of evaluating function's parameters is undefined. So you may receive different results in different compilers. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" gr

Re: [algogeeks] post and pre increment operators

2011-01-08 Thread Priyanka Chatterjee
b=(11++)+ (++10)=11+11=22 a=12 in printf the control goes to right first , i.e. ++a , so ++a =(++12), (a becomes 13 but ++a is not printed) then control moves to a but as the next expression pushed in stack is of the same variable so control moves to a++. without printing a a++= 13++, (now a beco

Re: [algogeeks] post and pre increment operators

2011-01-08 Thread kartheek muthyala
Hey priya, Ok let me analyse it once again... keep this logic in mind... 1. if it is a post increment directly use the same value without incrementing and then increment. 2. if it is a preincrement (increment a and then wait) or operand with no operation then wait for its first operand to complete

Re: [algogeeks] post and pre increment operators

2011-01-08 Thread priya mehta
ok but the output of int a=10,b; b=a++ + ++a; printf("%d,%d,%d,%d",b,a++,a,++a); is 22 13 14 14 howz that then? On Sun, Jan 9, 2011 at 11:11 AM, kartheek muthyala wrote: > Yeah you might be knowing how the expression evaluators work using stack > right. printf also uses the same approach > >

Re: [algogeeks] post and pre increment operators

2011-01-08 Thread kartheek muthyala
Yeah you might be knowing how the expression evaluators work using stack right. printf also uses the same approach On Sun, Jan 9, 2011 at 11:06 AM, priya mehta wrote: > @kartheek so does it use stack for that? > > > On Sun, Jan 9, 2011 at 11:03 AM, priya mehta wrote: > >> ok >> i got that >>

Re: [algogeeks] post and pre increment operators

2011-01-08 Thread priya mehta
@kartheek so does it use stack for that? On Sun, Jan 9, 2011 at 11:03 AM, priya mehta wrote: > ok > i got that > > On Sun, Jan 9, 2011 at 11:01 AM, kartheek muthyala < > kartheek0...@gmail.com> wrote: > >> small correction printf evaluation starts from right to left. >> >> >> On Sun, Jan 9,

Re: [algogeeks] post and pre increment operators

2011-01-08 Thread priya mehta
ok i got that On Sun, Jan 9, 2011 at 11:01 AM, kartheek muthyala wrote: > small correction printf evaluation starts from right to left. > > > On Sun, Jan 9, 2011 at 10:59 AM, kartheek muthyala > wrote: > >> @priya, >> >> Generally printf evaluation starts from left to right >> so first a

Re: [algogeeks] post and pre increment operators

2011-01-08 Thread kartheek muthyala
small correction printf evaluation starts from right to left. On Sun, Jan 9, 2011 at 10:59 AM, kartheek muthyala wrote: > @priya, > > Generally printf evaluation starts from left to right > so first a++ using post increments assign the value of 3rd %d to be 2 > then a++gets evaluated , no

Re: [algogeeks] post and pre increment operators

2011-01-08 Thread kartheek muthyala
@priya, Generally printf evaluation starts from left to right so first a++ using post increments assign the value of 3rd %d to be 2 then a++gets evaluated , now a value is 3 2nd %d takes a value as 3 1st %d takes a value as 3 if it is a preincrement like ++a in the third place the output will

[algogeeks] post and pre increment operators

2011-01-08 Thread priya mehta
int a=2; printf("%d %d %d",a,a,a++); the output is 3 3 2 can someone tell the logic behind this? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group,