Increment Operator (++):
Increment Operator increases the value by “1”. There are two types of increment operators: Pre increment operator and Post increment operator.
Post increment:
Consider the example
int X=3,Y;
Y=X++;
In the above statement ‘X’ value becomes 4 and ‘Y’ takes 3.
Pre increment:
Consider the example
int X=3,Y;
Y=++X;
In the above statement ‘X’ value becomes 4 and ‘Y’ also takes 4.
Decrement Operator (--):
Decrement Operator decreases the value by “1”. There are two types of decrement operators: Pre decrement operator and Post decrement operator.
Post decrement:
Consider the example
int X=3,Y;
Y=X--;
In the above statement ‘X’ value becomes 2 and ‘Y’ takes 3.
Pre decrement:
Consider the example
int X=3,Y;
Y=--X;
In the above statement ‘X’ value becomes 2 and ‘Y’ also takes 2.
0 comments:
Post a Comment