Different answer in different compiler

x=8;
x-=–x-x–;
printf(“x=%d”,x);
What’s the answer???

Such Expressions are compiler dependent and thus you are getting different answers in different compilers.

There is a rule called “sequence point rule” in C. We are not allowed to modify a memory location more than once or read and write the same location (reading other than for the purpose of getting a value to write) between two sequence points. If we do this, the result is “Undefined”. So it is left to the Compiler to decide how to evaluate such expressions and thus the answers across different Compilers vary.

Reference: http://gatecse.in/wiki/Undefined_Value