Increment and Decrement Operators in C++

These operators also fall under the broad category of unary operators but are quite distinct than unary minus. The increment and decrement operators are very useful in C++ language. They are extensively used in for and while loops. The syntax of these operators is given below: ++<variable name> <variable name>++ –<variable name> <variable name>– The operator ++ adds 1 to the operand and — subtracts 1 from the operand. These operators manifest in two forms: prefix and postfix. For example, the ++ operator can be used in two ways: ++m and m++ These are two different expressions. The first expression immediately increments the value of m by 1. For example, the statements: int t, m = 1; t = ++m; will cause the value of m to incremented first, and then this value is assigned to t, resulting in both having the same value. On the other hand, the statements:...