Y= --x +( --x + --x); // outputs y as 6.
Y= (–x + --x) + --x; outputs y as 8.
Any explanation? Please.
Both of the statements,
Y = --x + (–x + --x)
Y = (-x + --x) + --x
form invalid C code because they give rise to undefined behaviour (due to violation of the sequence point rules). No one really should write code like this.
But, if you are still interested, you should take a look at the assembly generated. Hope you can make sense out of that.
Hope This Help
Thanks for such fast response.