Write a Program to demonstrate Increment Operator in C

#include<stdio.h>
#include<conio.h>
void main()
{
int x=10,y=20;

/*Pre Increment*/
printf("\n\n\t\tPre-Increment");
printf("\n\n\t\tnBefore increment X=%d",x);
++x;
printf("\n\n\t\tAfter Increment X=%d",x);

//Post Increment

printf("\n\n\t\tPost-Increment");
printf("\n\n\t\tBefore increment Y=%d",y);
y++;
printf("\n\n\t\tAfter Increment X=%d",y);
getch();

}

Previous
Next Post »