increment operator: ++var_name; (or) var_name++;
Decrement operator: --var_name; (or) var_name--;
Let a=5 then
a++; // becomes 6
a--; //becomes 5
#include<stdio.h>
#include<conio.h>
void main( ) {
int i=1;
while(i<10) {
printf(“%d”,i);
i++;
}
}
123456789
#include<stdio.h>
#include<conio.h>
void main( ) {
int i=20;
while(i>10) {
printf(“%d”,i);
i--;
}
}
20 19 18 17 16 15 14 13 12 11
Pre increment means adding 1 to the value before assigning it to variable ex: ++i;
Post increment means adding 1 to the value after assigning it to variable ex: i++;
Pre decrement means subtracting 1 from the value before assigning it to variable ex: --i;
Post decrement means subtracting 1 from the value after assigning it to variable ex: i--;