-- (Self-decrease)

From Microduino Wiki
Revision as of 05:48, 17 August 2016 by Fengfeng (talk) (Created page with "-- (Self-decrease) *'''Description''' Increasing or decreasing a variable *'''Syntax''' <pre style="color:green"> x++; //x self-adds 1, and return the original value of x...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

-- (Self-decrease)

  • Description

Increasing or decreasing a variable

  • Syntax
 
x++;  //x self-adds 1, and return the original value of x.
++x;  // x self-adds 1, and return the new value of x.
 
x--;  // x self-decreases 1, and return the original value of x.
--x;  //x self-decreases 1, and return the new value of x. 
  • Parameters
x: in or long(maybe unsigned)

Return

The original or new value after the self-addition or self-decrease of a variable.

  • Example
x = 2;
y = ++x;      // Now, x=3, y=3
y = x--;      // Now, x=2, y=3

[Return to Arduino Syntax Manual]