Chapter 3 Self-Quiz

True/False Indicate whether the statement is true or false.

____1.When the computer executes the statement area = length * width; it uses whatever values are stored in the variables length and width at the time the assignment is executed. If no values have been specifically assigned to these variables before they are used in the expression length * width, the computer looks ahead to see the values you assign to these variables later in the program.

____2.The expression n-- and --n both reduce the value of n by 1.

____3.Unlike the increment operators, the prefix and postfix decrement operators produce different results when used in assignment expressions.

____4.The argument to the sqrt function must be a rational number.

____5.Each time a mathematical function is used, it is called into action by giving the name of the function and passing any data to it within the parentheses following the function’s name.

____6.A function may not be included as part of larger expressions.

____7.The expression int (a * b) ensures that the value of the expression a * b is converted to an integer value.

____8.The C type cast syntax does not work in C++.

____9.Any number of statements using the cin object may be made in a program, but only one value may be input using a single cin statement.

____10.Strictly speaking, what comes in from the keyboard is not any data type, such as int or double, but is simply a sequence of characters.

____11.A well-constructed program should validate user input and ensure that a program does not either crash or produce nonsensical output due to unexpected input.

____12.Equating numbers to symbolic names is accomplished by means of a const declaration qualifier.

____13.After a const identifier is created and initialized, the value stored in it can be updated.

____14.In C++ a variable or symbolic constant must be declared before it is used.

____15.The expression (count + n)++ is a valid expression.

Multiple Choice

Identify the choice that best completes the statement or answers the question.

____16.Any expression that is terminated by a ____ becomes a C++ statement.

A) / colon / C) / curly bracket
B) / semicolon / D) / period

____17.If b is an integer and d is a double-precision number, the evaluation of the expression b*d is a(n) ____ value.

A) / integer / C) / real
B) / float / D) / double-precision

____18.When the ++ operator appears before a variable, it is called a(n) ____ increment operator.

A) / leading / C) / ordered
B) / prefix / D) / postfix

____19.The purpose of the parentheses after a function name is to provide a funnel through which data can be ____.

A) / output / C) / passed to the function
B) / checked / D) / stored

____20.In C++ there are ____ square root functions all named sqrt, with the data type of the argument determining which function is actually called.

A) / one / C) / three
B) / two / D) / four

____21.The data type returned by abs(x) is ____.

A) / real / C) / integer
B) / float / D) / the same data type as x

____22.The value of pow(x1, x2) is ____.

A) / x1 raised to the x2 power / C) / the square of x1 + the square of x2
B) / x2 raised to the x1 power / D) / x1 * x2

____23.The operator used to force the conversion of a value to another type is the ____ operator.

A) / coercion / C) / switch
B) / cast / D) / convert

____24.The compile-time cast is a ____ operator having the syntax dataType (expression).

A) / unary / C) / coercive
B) / binary / D) / switch

____25.The cinextraction operation ____ data type conversions.

A) / always makes the correct / C) / can make some
B) / can make no / D) / makes only integer to float

____26.The term validate means checking that the entered value ____ the data type of the variable that the value is assigned to within a cin statement.

A) / is different from / C) / is similar to
B) / matches / D) / none of the above

____27.If it is necessary to change the value of a constant with a symbolic name, the change need only be made ____.

A) / at compile time / C) / twice
B) / once / D) / at execution time

____28.Using ____ letters is customary in C++ to make const identifiers easy to identify.

A) / lowercase / C) / bold
B) / italic / D) / uppercase

____29.As a general rule, do not use ____ in an expression where the variable it operates on appears more than once in the expression.

A) / any operator
B) / the increment operator
C) / the decrement operator
D) / either the increment or the decrement operator

____30.The extraction operator used with cin is ____.

A) / C) / ,
B) / D)

Chapter 3 Self-Quiz

Answer Section

TRUE/FALSE

1.ANS:FPTS:1REF:82

2.ANS:TPTS:1REF:90

3.ANS:FPTS:1REF:90

4.ANS:FPTS:1REF:107

5.ANS:TPTS:1REF:109

6.ANS:FPTS:1REF:109

7.ANS:TPTS:1REF:111

8.ANS:FPTS:1REF:111

9.ANS:FPTS:1REF:119

10.ANS:TPTS:1REF:121

11.ANS:TPTS:1REF:121

12.ANS:TPTS:1REF:127

13.ANS:FPTS:1REF:127

14.ANS:TPTS:1REF:128

15.ANS:FPTS:1REF:132

MULTIPLE CHOICE

16.ANS:BPTS:1REF:83

17.ANS:DPTS:1REF:84

18.ANS:BPTS:1REF:89

19.ANS:CPTS:1REF:107

20.ANS:CPTS:1REF:107

21.ANS:DPTS:1REF:108

22.ANS:APTS:1REF:108

23.ANS:BPTS:1REF:111

24.ANS:APTS:1REF:111

25.ANS:CPTS:1REF:121

26.ANS:DPTS:1REF:121

27.ANS:BPTS:1REF:127

28.ANS:DPTS:1REF:128

29.ANS:DPTS:1REF:132

30.ANS:BPTS:1REF:132