C - Operators
Arithmethic Operators - Binary Operators
This operators need two elements to execute.
Arithmethic Operators - Unary Operators
This operators need only one element to execute.
- Unary increment operator
x++
Equivalent tox = x+1
- Unary decrement operator
x--
Equivalent tox = x-1
But both the increment and decrement operator can appear on either side of an expression:
Pre-incrementing
uint32_t x,y;
x = 5;
y = ++x;
result
y = 6, x =6
Here the variable x
is first incremented and then evaluated.
Post-incrementing
uint32_t x,y;
x = 5;
y = x++;
result
y = 5, x =6
Here the variable x
is first evaluated and then incremented, that's why the y
variable has the initial value of x
instead of the incremented one.