This operator increases the value of the variable by 1. The above expression is same as m = m + 1 or m += 1.
Types of Increment Operators in C.
1.Prefix Increment Operator: When we use this operator, the value of the variable first increases by 1 and then the variable is used inside the expression.
2.Postfix Decrement Operator: When we use this operator, the variable is used inside the expression with its original value and then its value is increased by 1.
Syntax
// Prefix++a;
// Postfix
a++;
Example:
#include <stdio.h>
int main() {
int a1 = 7, a2 = 7;
// First the value of a1 is printed and then a1 increases by 1.
printf("%d\n", a1++);
// First the value of a2 increases by 1 and then the new value of a2 is printed.
printf("%d\n", ++a2);
return 0;
}
Output