Friday, 15 May 2015

Increment and Decrement Operators

  • Increment and Decrement Operators are Unary Operators(Unary Operator Operates on One Operand).
  • Increment Operator is Used to Increment Value of variable by 1 (default).
  • Decrement Operator is used to decrement value of Variable by 1 (default).
Types of increment and decrement operators.

1.  Pre Increment / Pre Decrement Operator

2.  Post Increment / Post Decrement Operator

Syntax:

++ Increment operator : increments a value by 1
-- Decrement operator : decrements a value by 1


Pre-Increment Operator:

“++” is written before Variable name.

Value is Incremented First and then incremented value is used in expression.

Post-Increment Operator:

“++” is written afterVariable name.
Increment Value of Variable After Assigning.




No comments:

Post a Comment