Increment and decrement operators are unaryoperators that add or subtract one from their operand, respectively. They are commonly implemented inimperativeprogramming languages. C-like languages became notorious for featuring two versions (pre- and post-) of each operator with slightly different semantics.
// Increment operators
x = 1;
y = ++x; // x is now 2, y is also 2
y = x++; // x is now 3, y is 2
// Decrement operators
x = 3;
y = x--; // x is now 2, y is 3
y = --x; // x is now 1, y is also 1
May 10th, 2014
Did you know? You can earn $20 for every friend you invite to Studypool!