y = ++x ; y becomes 3
y = x++ ; y becomes 2 and x becomes 3 in both cases.
But as per rule of precendance... ++ operator has higher priority than = operator.
Then as per precendance .. y should become 3 in both the cases owing to higher precendance to ++ than =.
But it doesn't happen , why ? What is the possible bug or behavior of compiler ?
"y = x++" means increment x after evaluating the expression.
So in this case, the expression is evaluated while x still equals 2, thus setting y to 2, and then after that evaluation is finished, x is incremented.
I totally agree with lambtron and echo47, ++X and X++ are two different things.
Maybe if your code was:
++X;
X++;
Then there won’t be much difference but since you added an “=” to the expiration they will have two different effects.