C Program#157 – Understanding Increment (++) and Decrement (−−) Operators in C.

Program to Understand Increment (++) and Decrement (−−) Operators in C.:

Brief Info. : Increment (++) & Decrement (−−) Operators

  • Increment (++) Operator , increases the value of it’s operand by 1.
  • That means : x++ , is equivalent to x=x+1;.
  • Decrement (−−) Operator , decreases the value of it’s operand by 1.
  • That means : x−−, is equivalent to x=x-1;.
  • Both Operators (++/−−) , have Prefix (++x/−−y) and Postfix(x++/x−−) versions available in C.
  • Prefix (++x or −−x) , applies Before evaluation of expression.
  • Postfix (x++ or x−−) , applies After evaluation of expression.
  • Precedence of Unary Operators are Higher than Binary Operators and Associativity is Right to Left.
  • If both versions mixed in an expression, Postfix evaluates First, Then Prefix evaluates.
  • Still not understood ? See the proper working example in action below.




Full Well Commented, Self-Explanatory Example Program of the same given below.

Below Here is the Output of the program.



Output of the Program :