Increment & Decrement operators ...........


Increment & Decrement operators:




The operator which is used to increase operand value by one is called increment operator.         

The operator which is used to decrease operand value by one is called decrement operator.

  Since both increment and decrement operators operate on single operand, we call these two operators as Unary operators.
         



Operator

Description

Example 1

Example 2

 ++

 Increment operator

 x++

++ x

--

Decrement operator

x--

--x

 Post increment:
     If the unary plus (increment operator) is placed after an operand, the value of the operand is altered after its utilization.

  Let x= 5

 X++;

 The value of the operand X is 6 after the expression gets executed.

Pre increment: 
      If the unary plus (increment operator) is placed before an operand, the value of the operand is altered before its utilization.

  Let x= 5

 ++X;
 The value of the operand X is 6 before the expression gets executed.
Post decrement:
    If the unary minus (decrement operator) is placed after an operand, the value of the operand is altered after its utilization.

  Let x= 5

 X--;

 The value of the operand X is 4 after the expression gets executed.

Pre decrement: 
   If the unary plus (increment operator) is placed before an operand, the value of the operand is altered before its utilization.

  Let x= 5

 --X;

 The value of the operand X is 4 before the expression gets executed.