go to previous page   go to home page   go to next page highlighting

Answer:

This decrements (by one) the value in the variable: count-- ;


Postfix Decrement Operator

The effect of count-- ; is the same as

count = count - 1;

Both ++ and -- can be placed in front of the variable:

++j;      // same effect as j = j+1;

--j;      // same effect as j = j-1;

In these cases the operators are called prefix operators. Either ++j; or j++; can be used for the same effect, although it is best to be consistent.

Good Advice: All four operators can be used in more complex expressions, but doing so is usually not wise. Evaluating an arithmetic expression that includes these operators can be confusing. AP Computer Science recommends using these operators only in statements consisting of the variable and the operator.

One of the following chapters discusses this subject in more detail.


QUESTION 16:

Which of the following statements does not follow the good advice?

count++ ;

count = count++ + 1;

--j;

go to previous page   go to home page   go to next page