C - Increment and Decrement Operators


The increment operator ++ and the decrement operator -- will increment or decrement the value stored in the integer variable.

number currently has the value 6. You can increment it by 1 with the following statement:

++number;// Increase the value by 1

After executing this statement, number will contain the value 7.

You could decrease the value of number by 1 with the following statement:

--number;                              // Decrease the value by 1

The increment and decrement operators modify the value of their operand.

The expression --number modified the value in number by subtracting 1 from it.

The expression ++number adds 1 to the value stored.

Related Topics