Pre-Decrement Operator
If the -- is before the variable then the decrementing is done first.
int amount, count;
count = 3;
amount = 2 * --count;
1 gets subtracted from count first, then amount gets the value of 2 * 2 or 4
So after executing the last line, amount is 4 and count is 2.
Previous slide
Next slide
Back to first slide
View graphic version