Table of Contents
The decrement operator -- decreases the value of an operand by 1. Like the increment operator, it can be written before or after the operand.
#include <stdio.h>
int main()
{
int number = 5;
number--;
printf("number = %d\n", number);
return 0;
}
Example Output #
number = 4
Explanation #
The decrement operator is applied to number:
number--;
This decreases its value from 5 to 4.
The decrement operator has two forms:
--number;
number--;
Both forms decrease the operand by 1. The difference between the prefix and postfix forms matters when the decrement operation is used as part of a larger expression.