Multiple Choice Identify the
letter of the choice that best completes the statement or answers the question.
|
|
|
1.
|
Which of the following declarations would properly create A and B as integer
variables?
a. | int A, B | c. | int A; B | b. | A, B int | d. | int A B |
|
|
|
2.
|
Which of the following expressions is a concatenation operation?
a. | ("append" + "age") | c. | "there" | b. | x / y | d. | 1+ 2 + 3 |
|
|
|
3.
|
Tell if the expression is double, int, or neither: 4 + 3.0
|
|
|
4.
|
Which of the following expressions would assign the sum of A, B, and C to the
variable D?
a. | sum (D = A + B + C) | c. | D <=
A + B + C | b. | A + B + C =
D | d. | D =
A + B + C |
|
|
|
5.
|
What is a correct precedence rule for the arithmetic operators listed?
a. | % / * - + | c. | + * % / - | b. | / % + - * | d. | * % / + - |
|
|
|
6.
|
Tell if the expression is double, int, or neither: 3.0 + 4.0
|
|
|
7.
|
A prompting message ____.
a. | should tell what type of input is desired | b. | can be used with
both input and output statements | c. | explains to the user what is to be
done | d. | All of the above. |
|
|
|
8.
|
A correct statement to get values for the variables A, B, and C would be:
a. | cin >> A >> b >> c | c. | cin >>A >> B >>
C | b. | cin >> A, B, C | d. | cin >> A >> B >> C >>
endl |
|
|
|
9.
|
Which of the following statements would assign the value of 40 to the variable
Test8?
a. | Test8 = 40 | c. | 40 = Test8 | b. | Test8 <
= 40 | d. | cin >>
(Test8 = 40) |
|
|
|
10.
|
Assume the following: #include "apstring.h" apstring city;
Which of the
following statements prompts the user to enter the name of their city and then reads the string to
variable city?
a. | cin >> "Enter your city: "; cout << city; | b. | cout << "Enter
your city: "; getline (cin, city); | c. | cout << "Enter your city: "; cin >>
city; | d. | cout << "Enter your city: "; getline >> city; |
|
|
|
11.
|
What operator can be used for arithmetic conversions?
a. | multiplication | c. | left paren | b. | minus | d. | modulus |
|
|
|
12.
|
Tell if the expression is double, int, or neither: 5 / 3
|
|
|
13.
|
Which is not a rule in an assignment statement?
a. | Constants can be on the left side of the assignment symbol. | b. | The previous value
of a variable is always thrown away. | c. | No constants on the left side of the assignment
symbol. | d. | Variable and expression are of compatible data types. |
|
Problem
|
|
|
14.
|
Find the value of the expression: 14 + 75 * (18 - 5 % 2)
|
|
|
15.
|
Find the value of the expression: 8 - 7 / 3
|
|
|
16.
|
Find the value of the expression: 7 + 4 * 12
|
|
|
17.
|
Find the value of the expression: 3.5 + 8.7 / 2.1
|
|
|
18.
|
Find the value of the expression: 12 * 4 + 7
|
|
|
19.
|
Find the value of the expression: 5.2 * 2.0
|
|
|
20.
|
Find the value of the expression: 12 % 3 * 6 - 7
|
True/False Indicate whether the
sentence or statement is true or false.
|
|
|
21.
|
The getline function reads all of the characters on a
line up until the first blank space is encountered.
|
|
|
22.
|
A temporary output statement in your program is one debugging technique.
|
|
|
23.
|
The empty string is represented by NULL.
|
|
|
24.
|
Multiplication is evaluated before addition.
|
|
|
25.
|
Character constants assigned to a character variable require double quotation
marks for enclosing the constant.
|
|
|
26.
|
The function to round off real numbers is called int.
|
|
|
27.
|
The concatenation operator changes the contents of its operands.
|
|
|
28.
|
Declaring a variable sets aside a memory location for its storage in the
computer.
|
|
|
29.
|
The assignment statement, x += y, can represent an arithmetic operation or a
concatenation operation.
|
|
|
30.
|
A variable declared with string can be assigned to a variable declared with
"char".
|
|
|
31.
|
Constants should be declared if numbers are to be used frequently in a
program.
|