Increment and Decrement Operators
Increment and decrement operators are used to increase or decrease the value of a variable by one, respectively. The increment operator is `++` and the decrement operator is `--`.
- Increment (++): Increases the value by one.
- Decrement (--): Decreases the value by one.
Increment Example:
#include <stdio.h>
int main() {
int a = 5;
a++; // Increment
printf("Value of a after increment: %d\n", a);
return 0;
}
Output
Value of a after increment: 6
Decrement Example:
#include <stdio.h>
int main() {
int a = 5;
a--; // Decrement
printf("Value of a after decrement: %d\n", a);
return 0;
}
Output
Value of a after decrement: 4