CodesandTutorials
Next generation website theme is here (black, neon and white color) - Reduces eye strain and headache problems.
You are here - Home > Programming > C > Basics

Increment and Decrement Operator


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.

Tip Box

Remember

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

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


Advertisement





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