Decrements the value of a variable by 1.


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

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

Parameter Values

  • x: variable. Allowed data types: int, long (possibly unsigned).

Return Values

  • The original or newly decremented value of the variable.

Example Code

x = 2; y = --x; // x now contains 1, y contains 1 y = x--; // x contains 0, but y still contains 1
Please note: These are affiliate links. If you buy the components through these links, We may get a commission at no extra cost to you. We appreciate it.