A question in the exam should be based on the compiler, but the question is not mentioned. Assume it is in the GCC environment. The general solution steps are as follows:
1. calculate all the first incremental operations, that is, calculate all the ++ X first.
2. Obtain the value of the expression containing X.
3. After the incremental operation is executed, X ++ is calculated.
For example:
Int x = 9, Y;
Y = x ++;
There are two expressions (x ++) containing X. The value is 9, so the value of Y is 18, and the value of X is 11.
If y = ++ x ++ X;
Then, calculate the value of ++ X, X is 11, and then the value of the two expressions of X, so y is 11 + 11 = 22.
If y = ++ x ++;
Then, calculate the number of ++ X, X is 11, and then the value of the three expressions of X, that is, 11 + 11 + 11 = 33, and then calculate the value of X ++, finally, X is 12.
The same is true for -- X and X.
For example, y = -- X + -- X/2;
The result is y = 10, x = 7.