[Compound Operators]
Description
Increments the value of 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
Parameters
x
: variable. Allowed data types: int
, long
(possibly unsigned).
Returns
The original or newly incremented value of the variable.
Example Code
x = 2; y = ++x; // x now contains 3, y contains 3 y = x++; // x contains 4, but y still contains 3
Language Reference Home
The text of the 86Duino reference is a modification of the Arduino reference and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.