To increment by 1 the value of an integer variable x, we can use any of the following three statements, which are all equivalent:
Note that the most compact form is the one using the post-increment operator ++.x = x + 1; x += 1; x++;
Similarly, to decrement by 1 an integer variable, we can use any of the following three statements, which are all equivalent:
Also in this case, the most concise form is the one that uses the post-decrement operatorx = x - 1; x -= 1; x--;
--
.