Definition
The ++ (increment) and -- (decrement) operators take a single
argument.
In an assignment statement, the operand’s placement before or
after the operand determines whether the increment/decrement
operation takes place before or after the assignment.
-
If the operator appears before the
operand (++n), the increment or decrement operation occurs before
the assignment
-
If the operator appears after the
operand (n++), the increment or decrement operation occurs after
the assignment
Examples
// The following three statements are equivalent:
i++
i = i + 1
i += 1
// Increment n before assignment.
// Afterwards, both x and n have the value 11.
n = 10
x = ++n
// Increment n after assignment.
// Afterwards, x is 10 and n is 11.
n = 10
x = n++