Increment and Decrement Operator
Description
These opeators are used to increment or decrement the value of a variable. There are two ways to do it by using prefix, meaning that the operator precedes the variable eg: ++count. Second is postfix meaning that operator follows the variable eg: count++.
For eg: a = ++count;
In this statement value of count is incremented by 1 and then assigned to the variable a.
Second eg: a = count++;
In this value of count variable is assigned to variable a and then incremented by 1.
Types
Increment operator
- Adds 1 to the value of its variable.
- It is represented by '++' operator
Decrement operator
- Subtracts 1 from the value of its variable.
- It is represented by '--' operator.