0% Complete
0/25 Steps

# Increment Decrement Operators

Lesson Progress
0% Complete

## Increment Operator

The increment operator is an Arduino arithmetic operator that increments an integer variable by a value of one. This is useful in certain types of loops.

Two possible structures of increment operator:

1. Variable_Name++ : As the ++’ sign is after the variable name, it is a post increment operation. This means that the variable is first used in the statement and incremented after the statement execution.
2. ++Variable_Name: As the ‘++’ sign is before the variable name, it is a pre increment operation. This means that the variable is incremented before the execution of the statement.

Example showing the working of the post increment operation:

Example showing the working of the pre increment operation:

## Decrement Operator

The decrement operator is used to decrement an integer variable by a value of one.

Two possible structures of increment operator:

• Variable_Name – – : As the –‘ sign is after the variable name, it is a post decrement operation. This means that the variable is first used in the statement and decremented after the statement execution.
• – – Variable_Name : As the –‘ sign is before the variable name, it is a pre decrement operation. This means that the variable is decremented before the execution of the statement.

Example of post decrement operation

Example of pre decrement operation:

## Conclusion

As now you have learned the increment and the decrement operators, we will move on to for loops in the next topic.