CodesandTutorials
Home   Programming   Hardware   Networking
 
Next generation website theme is here (black, neon and white color) - Reduces eye strain and headache problems.  

C Categories

Increment and Decrement Operator

« Previous Point - Shift Operators Next Point - Ternary Operators »

Description

These opeators are used to increment or decrement the value of a variable. There are two ways to do it by using prefix, meaning that the operator precedes the variable eg: ++count. Second is postfix meaning that operator follows the variable eg: count++.

For eg: a = ++count;
In this statement value of count is incremented by 1 and then assigned to the variable a.

Second eg: a = count++;
In this value of count variable is assigned to variable a and then incremented by 1.

Types

Increment operator

  • It is represented by '++' operator
  • Adds 1 to the value of its variable.

Decrement operator

  • It is represented by '--' operator.
  • Subtracts 1 from the value of its variable.

« Previous Point - Shift Operators Next Point - Ternary Operators »

Tip Box

Remember

You can increment or decrement value of variable, but not about constant

Eg: 1++; or (3+2)++;


Advertisement

Rate Website
   

 


Terms of Use | Privacy Policy | Contact Us
CodesandTutorials © 2014 All Rights Reserved