Hello Friends! Welcome to my Website,
C language based programming that is for increment and decrement operator. You can use this programming both error(compiler and runtime error) free programming just copy and paste the program and save your time.
c program to understand the use of postfix increment & decrement
#include
#include
void main()
{
int x;
printf(“Enter a Number”);
scanf(“%d” &x);
printf(“Number without postfix increment/decrement is =%dnn”,x);
printf(“Number with postfix increment is =%dn”,x++);
printf(“After postfix increment number is =%dn”,x);
printf(“Number with postfix decrement is =%dnn”,x–);
printf(“After postfix decrement number is =%dn”,x);
getch();
}
—-end code———-
Post means first print value then increment or decrement value.
Output:
Number without postfix increment/decrement is =5
Number with postfix increment is =5
After postfix increment number is =6
Number with postfix decrement is =6
After postfix decrement number is=5
Program to understand the use of prefix increment & decrement
#include
#include
void main()
{
int x;
printf(“Enter a Number”);
scanf(“%d” &x);
printf(“Number without prefix increment/decrement is =%dnn”,x);
printf(“Number with prefix increment is =%dn”,++x);
printf(“After prefix increment number is =%dn”,x);
printf(“Number with prefix decrement is =%dnn”,–x);
printf(“After prefix decrement number is =%dn”,x);
getch();
}
—-end code———-
Output:
Number without prefix increment/decrement is =5
Number with prefix increment is =6
After postfix increment number is =6
Number with prefix decrement is =5
After prefix decrement number is=5
I make this programming and hope you are like the post if are you like the post you can please comment and Share the post to reach more people.
If any dought about this c programming code or input & output please comment below
If you have other question about c programming send an email by contacting us form are given on page right side.
Thank You!