Hi , suppose you have a expression like int x= 1 , y = 2 , z = 0; z = x++ + ++y ;
now what happens is : 1) first the expression on the right hand side is evaluated as below : a) first all the prefix operators are applied to the operands . here in the above example since y has prefix operator y becomes 3 .
2) Now the expression is evaluated and the result of the expression is kept in a temporary location. 3) If the operands have any postfix operator that is evaluated for that operand .
4) Now the assignment to the LEFT HAND SIDE takes place . The LEFT HAND SIDE is given the value evaluated in the step 2 mentioned above .
..If you apply above rules correctly you should be able to get that the value of i as 2 . let us see what happens for int i = 1; i= i++;
if you follow my rules above then Step 1) Not applicable Step 2) the value of the expression is 1. Step 3) the value of i becomes 2 Step 4) the value of the expression evaluated to 1 is now assigned to i ( overwriting the value 2 )