Re: [algogeeks] Help with Increment Operators in C!

2010-08-29 Thread prasad rao
In printf, the cursor goes to left to right. so x++ + ++x + x++ 5 + 7 +7 = 19. ( Here x=5, then we put 5 in place of first x, after that x will be incremented(post increment) that means x is 6 and we take second x which is pre-increment and hence once again x will be incremented that means x is 7

Re: [algogeeks] Help with Increment Operators in C!

2010-08-29 Thread Manjunath Manohar
it is compiler dependant da..the evaluation of this kind of expressions -- 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, send email to

[algogeeks] Help with Increment Operators in C!

2010-08-28 Thread jagadish
I ran this code.. int main() { int x=5; printf(%d,(x++ + ++x + x++)); } The output printed was 18 instead of 19.. Should it not be 19? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] Help with Increment Operators in C!

2010-08-28 Thread vineeth mohan
it sud b 19 naaa x++ = 5 ++x = 7 x++ = 7 5+7+7 On Sat, Aug 28, 2010 at 4:35 PM, jagadish jagadish1...@gmail.com wrote: I ran this code.. int main() { int x=5; printf(%d,(x++ + ++x + x++)); } The output printed was 18 instead of 19.. Should it not be 19? -- You received this message

Re: [algogeeks] Help with Increment Operators in C!

2010-08-28 Thread Priyanka Chatterjee
output is 18 1. control goes to ++x =6 ,x=6 2. control goes to both x++, i.e. both x++ are evaluated together, therefore x++ + ++x + x++= 6 +6+6 =18 x=7 On 28 August 2010 17:05, jagadish jagadish1...@gmail.com wrote: I ran this code.. int main() { int x=5; printf(%d,(x++ + ++x + x++));

Re: [algogeeks] Help with Increment Operators in C!

2010-08-28 Thread Raj N
The output is undefined. Depends on the compiler. + is not a sequence point which may result in undefined behavior On Sat, Aug 28, 2010 at 5:05 PM, jagadish jagadish1...@gmail.com wrote: I ran this code.. int main() { int x=5; printf(%d,(x++ + ++x + x++)); } The output printed was 18