How to use postfix Increment and decrement in c language
Postfix Increment Decrement
On this page
Postfix Increment Decrement
Program to use Postfix Increment and Decrement in C Language
#include<stdio.h>
int main()
{
int s = 10;
printf("s = %d\t",s);
printf("s = %d\t",s++);
printf("s = %d\t",s);
printf("s = %d\t",s--);
printf("s = %d\n",s);
return 0;
}
Output
s = 10 s = 10 s = 11 s = 11 s = 10
Steps Description
- Declare integer variable s = 10
- Initialize in integer variable s = 10
- printf inbuild function to display value of variable s in decimal place holder %d s = 10 for formatting tab separator \t is used
- printf inbuild function to display postfix increment values variable s in decimal place holder %d s = 10 for formatting tab separator \t is used
- printf inbuild function to display value of variable s in decimal place holder %d s = 11 for formatting tab separator \t is used
- printf inbuild function to display post decrement values variable s in decimal place holder %d s = 11 for formatting tab separator \t is used
- printf inbuild function to display value of variable s in decimal place holder %d s = 10 for formatting tab separator \t is used