A ++ operator increments the value of the variable by one. By its result is dependent on the locatoin of the ++ operator. Value of the i++ expression is equal to the initial value of i variable (before the increment), but the value of the ++i expression is equal already incremented value of i variable.
First expression compares two values of the i variable:
- after the first increment (1) on the left
- before the second increment (1 again) on the right.
Schematically it may be depicted as follows: 0 → 1 == 1 → 2 true. is the result.
Second expression compares the following values of i varuable:
- before the third increase (2) on the left
- before the fourth increase (3) on the right
Schematically it may be depicted as follows: 2 → 3 == 3 → 4
And false. is the result this time