Increments Operators
- Post-increment:
var++
(var = var +1)var--
- Pre-increment:
++var
--var
Pre vs Post-increment:
- In an expression, the post-increment
a++
first performs the operation witha
, and then increments it by 1. Therefore:
In the first example, c
is assigned the current value of a
, then a
is incremented. In the second example, a
is incremented first, then its value is assigned to c
. In the third example, a
is incremented and c
is decremented after the subtraction operation.