Arduino Programming Language: Increment

Name

++ (increment) / - - (decrement)

Description

Increments or decrements a variable by 1.

Syntax

x++; // increment x by one and returns the old value of x
++x; // increment x by one and returns the new value of x
x-- ; // decrement x by one and returns the old value of x
--x ; // decrement x by one and returns the new value of x

Parameters

  • x: an integer or long (possibly unsigned)

Returns

 The original or newly incremented / decremented value of the variable.

Usage

Application

Examples

int a=2;
a++; //a contains 3

int a=10;
a--; //a contains 9


Based on the reference originally written by Arduino Community,  wiring.org.co and  arduino.cc