There are two special arithmetic operators called increment and decrement operators available C. They are unary operators unlike all other arithmetic operators. The operators are denoted as : '++' (increment operator), '--' (decrement operator).
| Operator | Name | Description | Example |
|---|---|---|---|
| ++ | Increment Operator | Increments the value of operand by 1 | a++ : This is equivalent to a = a + 1 |
| -- | Decrement Operator | Decrements the value of operand by 1 | a-- : This is equivalent to a = a - 1 |
Variants of Increment and Decrement Operators - Pre Increment, Post Increment, Pre Decrement and Post Decrement
There are two different variants of increment and decrement operators known as pre increment, post increment, pre decrement and post decrement operators.
- Pre Increment Operators: When '++' is used as prefix of the operand, it's called pre increment operator. Pre increment operator will increment the value of operand before using it in the expression.
- Post Increment Operators: When '++' is used as postfix of the operand, it's called post increment operator. Post increment operator will increment the value of operand after using it in the expression. ie; The current expression will use non-incremented value of operand.