/*
In C/C++, Increment operators are used to increase the value of a variable by 1.
This operator is represented by the ++ symbol.
The increment operator can either increase the value of the variable by 1
before assigning it to the variable or can increase the value of the variable by 1
after assigning the variable. Thus it can be classified into two types:
-> Pre-Increment Operator
-> Post-Increment Operator
1) Pre-increment operator: A pre-increment operator is used to increment the value
of a variable before using it in an expression.
In the Pre-Increment, value is first incremented and then used inside
the expression.
Syntax:
a = ++x;
*/
/*
#include <stdio.h>
int main(){
int x=10,a;
//a = ++x;
printf("%d",++x); // increments after this inline
printf("%d",x); // incremented
printf("%d\n",a);
}
*/
/*
2) Post-increment operator: A post-increment operator is used to increment
the value of the variable after executing the expression completely in which
post-increment is used. In the Post-Increment,
value is first used in an expression and then incremented.
Syntax:
a = x++;
*/
#include <stdio.h>
int main(){
int x=10,a;
//a = ++x;
printf("%d\n",x++); // increments after this inline
printf("%d\n",x); // incremented
printf("%d\n",a);
}
To embed this program on your website, copy the following code and paste it into your website's HTML: