Header Responsive Ads

increment and decrement operators in c++

Increment operator (++)

The increment operator (++) increases the value of a variable by 1. It is mostly used inside a loop to increment the loop counter. Syntax of increment operator is below:

int number = 0;
number++;

number++ will increase the value of a variable number by 1.


Decrement operator (--)

The decrement operator (--) decreases the value of the variable by 1. It is also used in the loop when we need to decrement loop counter by 1 in each loop iteration. Syntax of decrement operator is below:


int number = 1;
number--;

number-- will decrease the value of a variable number by 1.

Both operators are unary operators as both work on only one operand. 

C++ Program to use increment and decrement operators:


increment and decrement operators in c++ with examples
Output
increment and decrement operators in c++ with examples output

Post a Comment

Previous Post Next Post

In Article Ads 1 Before Post

In Article Ads 2 After Post