CSC_Quiz3_SelfQuiz

advertisement
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
____ 19.
____ 20.
____ 21.
____ 22.
____ 23.
____ 24.
____ 25.
____ 26.
____ 27.
____ 28.
____ 29.
____ 30.
B) prefix
D) postfix
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
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
The data type returned by abs(x) is ____.
A) real
C) integer
B) float
D) the same data type as x
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
The operator used to force the conversion of a value to another type is the ____ operator.
A) coercion
C) switch
B) cast
D) convert
The compile-time cast is a ____ operator having the syntax dataType (expression).
A) unary
C) coercive
B) binary
D) switch
The cin extraction operation ____ data type conversions.
A) always makes the correct
C) can make some
B) can make no
D) makes only integer to float
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
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
Using ____ letters is customary in C++ to make const identifiers easy to identify.
A) lowercase
C) bold
B) italic
D) uppercase
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
The extraction operator used with cin is ____.
A) <<
C) ,
B) >>
D) <>
Chapter 3 Self-Quiz
Answer Section
TRUE/FALSE
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
F
T
F
F
T
F
T
F
F
T
T
T
F
T
F
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
REF:
REF:
REF:
REF:
REF:
REF:
REF:
REF:
REF:
REF:
REF:
REF:
REF:
REF:
REF:
82
90
90
107
109
109
111
111
119
121
121
127
127
128
132
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
PTS:
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
REF:
REF:
REF:
REF:
REF:
REF:
REF:
REF:
REF:
REF:
REF:
REF:
REF:
REF:
REF:
83
84
89
107
107
108
108
111
111
121
121
127
128
132
132
MULTIPLE CHOICE
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
ANS:
B
D
B
C
C
D
A
B
A
C
D
B
D
D
B
Download