Increment and Decrement Operators

The increment and decrement operators are very useful in C language. They are extensively used in for and while loops.
The syntax of these operators is given below.
++
++


The ++ operator increments the value of the variable by one, whereas the – operator decrements the value of the variable by one.

These operators can be used in either the postfix or prefix notation as follows:

Postfix: a++ or a–
Prefix: ++a or –a

Postfix notation

int a,b;
a = 10;
b = a++;
printf(“%d\n”,a);
printf(“%d\n”,b);

Program Output

10
11

Prefix notation

int a,b;
a = 10;
b = ++a;
printf(“%d\n”,a);
printf(“%d\n”,b);

Program Output

11
11

Back