Let it slow down and look hard at the equation. Think about it carefully.
int a = 5; int b = 7; int c = 10; c = b+++-c--+--a;
b ++ means increment b after assignment, so b remains equal to its original value in the equation, but after that it will increase.
Then a +.
Then the negation of c-- . c receives a decrement, but remains unchanged for the equation.
Then add this to -a, which means that a decreases immediately.
Thus, the values ββof the variables in the print statement will be:
c = 7 + -10 + 4 = 1 a = 4 b = 8
May I add that, in my opinion, this is a bad question for the test. All that he really asks if you understand i++ vs ++i .
source share