How to use prefix increment decrement in C Language
Prefix Increment Decrement
On this page
Prefix Increment Decrement
Program to use prefix increment decrement in C Language
#include <stdio.h>
int main()
{
int x = 8;
printf("x = %d\t", x);
printf("x = %d\t", ++x);
printf("x = %d\t", --x);
printf("x = %d\n", x);
return 0;
}
Output
x = 8 x = 9 x = 8 x = 8
Steps Description
- Declare integer variable x = 8
- Initialize in integer variable x = 8
- printf inbuild function to display value of variable x in decimal place holder %d = x for formatting tab separate or \t is used
- printf inbuild function to display prefix increment value variable x in decimal place holder %d = 9 for formatting tab separate or \t is used
- printf inbuild function to display variable x in decimal place holder %d = 9 for formatting tab separate or \t is used
- printf inbuild function to display prefix decrement x in decimal place holder %d x = 8 for formatting tab separate or \t is used
- printf inbuild function to display variable x in decimal place holder %d x = 8 for formatting tab separate or \t is used