True/False
Indicate whether the sentence or statement is true
or false.
|
|
|
1.
|
Character constants assigned to a character variable require double quotation marks
for enclosing the constant.
|
|
|
2.
|
The
empty string is represented by NULL.
|
|
|
3.
|
The
concatenation operator changes the contents of its operands.
|
|
|
4.
|
The
assignment statement, x += y, can represent an arithmetic operation or a concatenation
operation.
|
|
|
5.
|
A
variable declared with string can be assigned to a variable declared with
"char".
|
|
|
6.
|
The
getline function reads all of the characters on a line up until the first
blank space is encountered.
|
|
|
7.
|
Multiplication is evaluated before addition.
|
|
|
8.
|
Declaring a variable sets aside a memory location for its storage in the
computer.
|
|
|
9.
|
Constants should be declared if numbers are to be used frequently in a
program.
|
|
|
10.
|
The
function to round off real numbers is called int.
|
|
|
11.
|
A
temporary output statement in your program is one debugging technique.
|
Multiple Choice
Identify the
letter of the choice that best completes the statement or answers the question.
|
|
|
12.
|
What
is a correct precedence rule for the arithmetic operators listed? a. | * % / + -
| c. | + * % /
- | b. | % / * -
+ | d. | / % + -
* | | | | |
|
|
|
13.
|
What
operator can be used for arithmetic conversions? a. | minus | c. | multiplication | b. | modulus | d. | left
paren | | | | |
|
|
|
14.
|
Which
is not a rule in an assignment statement? a. | Variable and expression are of compatible data
types. | b. | No constants on the left side of the assignment
symbol. | c. | The previous value of a variable is always thrown
away. | d. | Constants can be on the left side of the assignment
symbol. | | |
|
|
|
15.
|
Which
of the following expressions is a concatenation operation? a. | "there" | c. | 1+ 2 + 3 | b. | x /
y | d. | ("append" + "age") | | | | |
|
|
|
16.
|
Tell
if the expression is double, int, or neither: 4 + 3.0
|
|
|
17.
|
Tell
if the expression is double, int, or neither: 3.0 + 4.0
|
|
|
18.
|
Tell
if the expression is double, int, or neither: 5 / 3
|
|
|
19.
|
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 | | | | |
|
|
|
20.
|
Which
of the following declarations would properly create A and B as integer variables? a. | int A,
B | c. | A, B
int | b. | int A;
B | d. | int A
B | | | | |
|
|
|
21.
|
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) | | | | |
|
|
|
22.
|
Which
of the following expressions would assign the sum of A, B, and C to the variable D? a. | D
= A + B + C | c. | D <= A + B +
C | b. | A +
B + C = D | d. | sum (D = A + B
+ C) | | | | |
|
|
|
23.
|
A
prompting message ____. a. | should tell what type of input is
desired | b. | explains to the user what is to be
done | c. | can be used with
both input and output statements | d. | All of the above. | | |
|
|
|
24.
|
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. | cout << "Enter your city:
";
getline (cin, city); | b. | cin >> "Enter your city:
";
cout << city; | c. | cout << "Enter your city:
";
cin >> city; | d. | cout << "Enter your city:
";
getline >> city; | | |
|
Completion
Complete each sentence or
statement.
|
|
|
25.
|
____________________ means the number is too large or too small to be
stored.
|
|
|
26.
|
____________________ or ____________________ overflow can occur when an arithmetic
operation occurs producing a number outside of your PC processor's range.
|
|
|
27.
|
Compound assignment operators provide a(n) ____________________ form for an expression
with a binary operator.
|
|
|
28.
|
The
following assignment statement is an aspect of software engineering called ____________________
code:
totalwords = GeographyText + BiologyText + CalculusText;
|
|
|
29.
|
For
the standard input stream, the extractor operator reads ____________________
characters.
|
|
|
30.
|
The
newline('\n') character can be used as a(n) ____________________ for an input stream.
|
|
|
31.
|
The
extractor operator (>>), is used to read a(n) ____________________ word into a string variable
and getline is for reading a(n) ____________________ of words into a string variable.
|
Short Answer
|
|
|
32.
|
What
arithmetic operation can generate a run-time error?
|
|
|
33.
|
What
arithmetic operation does the '%' represent?
|
|
|
34.
|
Why
is a data type of double used to represent an integer?
|
|
|
35.
|
What
is the difference between a constant and a variable?
|
|
|
36.
|
What
two methods can be used in C++ to represent constants?
|
|
|
37.
|
Assume A is an int with the value 5, B is a double with the value 3.56, and C is a
char with the value 'Q'. Examine for syntax and semantics. If it is invalid, state so. Otherwise give
the value assigned to the variable on the left hand side.
A = B
|
|
|
38.
|
Assume A is an int with the value 5, B is a double with the value 3.56, and C is a
char with the value 'Q'. Examine for syntax and semantics. If it is invalid, state so. Otherwise give
the value assigned to the variable on the left hand side.
B = A
|
|
|
39.
|
Assume A is an int with the value 5, B is a double with the value 3.56, and C is a
char with the value 'Q'. Examine for syntax and semantics. If it is invalid, state so. Otherwise give
the value assigned to the variable on the left hand side.
A = A + 1
|
|
|
40.
|
Assume A is an int with the value 5, B is a double with the value 3.56, and C is a
char with the value 'Q'. Examine for syntax and semantics. If it is invalid, state so. Otherwise give
the value assigned to the variable on the left hand side.
1B + 1 =
A
|
|
|
41.
|
Assume A is an int with the value 5, B is a double with the value 3.56, and C is a
char with the value 'Q'. Examine for syntax and semantics. If it is invalid, state so. Otherwise give
the value assigned to the variable on the left hand side.
A =
C;
|
|
|
42.
|
Declare M and N as character variables.
|
|
|
43.
|
Assign the letter K to the character variable Test12.
|
|
|
44.
|
Read
in values for the variables Test13A and Test13B.
|
|
|
45.
|
Write
the character variable N in a field 10 spaces wide and skip to the next line.
|
|
|
46.
|
Is
the following C++ statement valid. Assume that all variables have been properly
declared.
Test16 = Test16 + A;
|
|
|
47.
|
Is
the following C++ statement valid. Assume that all variables have been properly
declared.
4 + A =
Test17;
|
|
|
48.
|
Is
the following C++ statement valid. Assume that all variables have been properly
declared.
Test18 <= A / (B + C);
|
|
|
49.
|
Is
the following C++ statement valid. Assume that all variables have been properly
declared.
const int PI = 3.14159;
|
|
|
50.
|
Is
the following C++ statement valid. Assume that all variables have been properly
declared.
test 2 = 100;
|
|
|
51.
|
Write
a complete C++ program which, given the number of touchdowns, field goals, and extra points scored by
a football team, prints the total points they scored.
|
Problem
|
|
|
52.
|
Find
the value of the expression: 12 * 4 + 7
|
|
|
53.
|
Find
the value of the expression: 7 + 4 * 12
|
|
|
54.
|
Find
the value of the expression: 8 - 7 / 3
|
|
|
55.
|
Find
the value of the expression: 12 % 3 * 6 - 7
|
|
|
56.
|
Find
the value of the expression: 14 + 75 * (18 - 5 % 2)
|
|
|
57.
|
Find
the value of the expression: 3.5 + 8.7 / 2.1
|
|
|
58.
|
Find
the value of the expression: 5.2 * 2.0
|