It's output will be compiler dependent.
So on Turbo C, compiler will perform all pre-increment operation first then 
will start adding.
like in your problem all "++a" operation will go first. then addition will 
happen.
so 6+6+6=18.

on gcc, first two variables will it take, performs pre-increment operation 
and then adding and then third variable will come.as it continues.
As in this case in gcc it will be performed like,
(++a + ++a) + (a++)=(6+6)+6=18

post-increment will be unaffected during entire expression.

Feel free to ask if you didn't got what i explained.

On Monday, May 28, 2012 11:02:03 AM UTC+5:30, ashish wrote:
>
> #include<stdio.h>
> int main()
> {
>           int a=4;
>           printf("%d\n",++a + ++a + a++);
>           return 0;
> }       
>
> according to me output should be 17, but it is coming out to be 18.
> plz explain it?? 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/eBcLatQS34kJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to