Increment operator is used to increment or increase the value of a variable by one. It is equivalent to adding one to the value of the variable. The symbol used is ++. The decrement operator is used to decrement or decrease the value of variable by 1. It is equivalent to subtracting one from the value of the variable. The symbol used is --. Syntax: ++var or var++ for increment and --var or var--for decrement.
Example:
int m=5;
int n = ++m;
printf(%d%d”,m,n);
When the increment operator is used prior to the variable name m, the value of the variable m is incremented first and then assigned to the variable n. The values of both the variable m and n here will be 6. But if the increment operator ++ is used after the variable name, then the value of the variable m is assigned to the variable n and then the value of m is increased. Therefore the values of m and n will be 6 and 5 respectively.
Example for decrement operator
int m=5;
int n=--m;
printf(“%d%d”,m,n);
or
#include<stdio.h>
#include<conio.h>
void main() {
int m=4,n=6;
clrscr();
printf("values of m and n before changing%d%d",m,n);
m++;
n--;
printf("\nvalues after changing%d%d",m,n);
getch();
}