Increment Operator

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

Structures of increment operator:

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

Example of post increment operation:

Increment Operator

Example of pre increment operation:

pre increment operation:

Decrement Operator

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

Structures of decrement operator:

  • Variable_Name – – : As the sign is after the variable name, it is a post decrement operation. This means that the variable is used in the statement and only 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 execution of the statement.

Example of post decrement operation:

post decrement operation:

Example of pre decrement operation:

pre decrement operation: