C++ for Engineers and Scientists 4th Edition Gary J Bronson – Test Bank
To Purchase this Complete Test Bank with Answers Click the link Below
https://tbzuiqe.com/product/c-for-engineers-and-scientists-4th-edition-gary-j-bronson-test-bank/
If face any problem or
Further information contact us At tbzuiqe@gmail.com
Sample Test
Chapter 3: Assignment, Formatting, and Interactive Input
TRUE/FALSE
1. Program
execution begins with the first statement in the body of the main() function.
ANS: T
PTS:
1
REF: 108
2. The
stream manipulator lowercase displays hexadecimal digits and the exponent in
scientific notation in lowercase.
ANS:
F
PTS:
1
REF: 120-121
3. Numbers
sent to cout are normally displayed left-justified in the display field.
ANS:
F
PTS:
1
REF: 124
4. In
addition to outputting integers in decimal notation, the oct and hex
manipulators are used for conversions to octal and hexadecimal.
ANS:
T
PTS:
1
REF: 126
5. The
display of integer values in one of the three possible number systems (decimal,
octal, and hexadecimal) doesn’t affect how the number is stored in a computer.
ANS:
T
PTS:
1
REF: 126
6. The
ostream class method setf(ios::fixed) is equivalent to the stream manipulator
setiosflags(fixed).
ANS:
F
PTS:
1
REF: 129
7. Assignment
statements can be used to perform arithmetic computations.
ANS:
T
PTS:
1
REF: 133
8. In
C++, all functions, by definition, can directly return at most one value.
ANS:
T
PTS: 1
REF: 135
9. Using
a mathematical library function without including the preprocessor statement
#include <cmath> is a common programming error in C++.
ANS:
T
PTS:
1
REF: 170
10.
A common programming error in C++ consists of separating all
variables passed to cin with an extraction symbol, >>.
ANS:
F
PTS:
1
REF: 170
MULTIPLE CHOICE
1. A(n)
____ statement is the most basic C++ statement for assigning values to
variables and performing computations.
|
a. |
initialization |
c. |
declaration |
|
b. |
assignment |
d. |
arithmetic |
ANS:
B
PTS:
1
REF: 105
2. A(n)
____ is any combination of constants, variables, and function calls that can be
evaluated to yield a result.
|
a. |
expression |
c. |
class |
|
b. |
identifier |
d. |
object |
ANS:
A
PTS:
1
REF: 106
3. In
C++, the ____ symbol is called the assignment operator.
|
a. |
-> |
c. |
== |
|
b. |
>> |
d. |
= |
ANS:
D
PTS:
1
REF: 108
4. Because
of ____, the value assigned to the variable on the left side of the assignment
operator is forced into the data type of the variable to which it’s assigned.
|
a. |
right-to-left associability |
c. |
coercion |
|
b. |
left-to-right associability |
d. |
operator precedence |
ANS:
C
PTS:
1
REF: 110
5. A(n)
____ can have a value assigned to it.
|
a. |
lvalue |
c. |
uvalue |
|
b. |
rvalue |
d. |
dvalue |
ANS:
A
PTS:
1
REF: 110
6. In
C++, the expression sum = sum + 10 can be written as ____.
|
a. |
sum =+ 10 |
c. |
sum += 10 |
|
b. |
+sum = 10 |
d. |
sum = 10+ |
ANS:
C
PTS: 1
REF: 112
7. When
the ++ operator appears before a variable it’s called a(n) ____ increment
operator.
|
a. |
suffix |
c. |
postfix |
|
b. |
infix |
d. |
prefix |
ANS:
D
PTS:
1
REF: 115
8. To
control the format of numbers displayed by cout, you can include field width
____ in an output stream.
|
a. |
separators |
c. |
dividers |
|
b. |
manipulators |
d. |
escape sequences |
ANS:
B
PTS:
1
REF: 120
9. The
stream manipulator ____ sets the floating-point precision to n places.
|
a. |
setprecision(n) |
c. |
setfill(‘x’) |
|
b. |
setw(n) |
d. |
showbase |
ANS:
A
PTS:
1
REF: 120
10.
The stream manipulator ____ displays Boolean values as true and
false rather than 1 and 0.
|
a. |
booltext |
c. |
boolalpha |
|
b. |
bool |
d. |
showbool |
ANS:
C
PTS:
1
REF: 120
11.
When a manipulator requiring an argument is used, the ____
header file must be included as part of the program.
|
a. |
istream |
c. |
iostream |
|
b. |
ostream |
d. |
iomanip |
ANS:
D
PTS:
1
REF: 122
12.
In C++, the default precision is set to ____ decimal places.
|
a. |
five |
c. |
seven |
|
b. |
six |
d. |
eight |
ANS: B
PTS:
1
REF: 123
13.
To alter the default justification for a stream of data, you use
the ____ manipulator.
|
a. |
setiosflags |
c. |
setpos |
|
b. |
setw |
d. |
setjust |
ANS:
A
PTS: 1
REF: 124
14.
The term ____ refers to an item, such as a variable or argument,
that sets a condition usually considered active or nonactive.
|
a. |
expression |
c. |
flag |
|
b. |
variable |
d. |
constant |
ANS: C
PTS:
1
REF: 125
15.
Another name for a manipulator uses format flags is a ____
manipulator.
|
a. |
complex |
c. |
format |
|
b. |
parameterized |
d. |
customizable |
ANS:
B
PTS: 1
REF: 125
16.
The number 023 is a(n) ____ number in C++.
|
a. |
octal |
c. |
decimal |
|
b. |
hexadecimal |
d. |
binary |
ANS:
A
PTS:
1
REF: 126
17.
The ostream class method precision(n) is equivalent to the
stream manipulator ____.
|
a. |
precision() |
c. |
setprecision() |
|
b. |
setfill() |
d. |
setw() |
ANS:
C
PTS:
1
REF: 129
18.
The ostream class method setf(ios::flush) is equivalent to the
stream manipulator ____.
|
a. |
left |
c. |
right |
|
b. |
setiosflag(ios::flush) |
d. |
endl |
ANS:
D
PTS:
1
REF: 129
19.
In C++, the mathematical function ____ calculates a number’s
square root.
|
a. |
square() |
c. |
squareRoot() |
|
b. |
sqrt() |
d. |
sqroot() |
ANS:
B
PTS:
1
REF: 134
20.
In C++, accessing mathematical functions in a program requires
including the mathematical header file ____.
|
a. |
number |
c. |
cmath |
|
b. |
cnumber |
d. |
math |
ANS: C
PTS:
1
REF: 135
21.
The operator used to force converting a value to another type is
the ____ operator.
|
a. |
cast |
c. |
binary |
|
b. |
logical |
d. |
single |
ANS:
A
PTS: 1
REF: 137-138
22.
The ____ statement is used to enter data in a program while it’s
running.
|
a. |
input |
c. |
cout |
|
b. |
data |
d. |
cin |
ANS:
D
PTS:
1
REF: 143
23.
The ____ declaration qualifier specifies that the declared
identifier is read-only after it’s initialized.
|
a. |
fixed |
c. |
fix |
|
b. |
const |
d. |
unchanged |
ANS:
B
PTS:
1
REF: 154
24.
Identifiers created with const are commonly referred to as
symbolic constants or ____ constants.
|
a. |
general |
c. |
named |
|
b. |
global |
d. |
valid |
ANS:
C
PTS:
1
REF: 154
25.
A(n) ____ expression consists of operators and constants only.
|
a. |
constant |
c. |
initialization |
|
b. |
declaration |
d. |
arithmetic |
ANS:
A
PTS:
1
REF: 156
COMPLETION
1. The
simplest expression in C++ is a single ____________________.
ANS: constant
PTS: 1
REF: 105
2. A
variable can store only ____________________ value(s) at a time.
ANS:
one
1
PTS:
1
REF: 106
3. In
this statement: totalWeight = factor * weight;
the arithmetic expression factor * weight is evaluated first to
yield a number, which is then stored in the variable ____________________.
ANS: totalWeight
PTS:
1
REF: 107
4. In
C++, the = symbol is called the ____________________ operator.
ANS: assignment
PTS: 1
REF: 108
5. This
type of statement: sum = sum + 10; is called a(n) ____________________
statement.
ANS: accumulation
PTS:
1
REF: 113
6. If n
= 25 and this statement is executed: n–; , then the new value of n is ____________________.
ANS: 24
PTS:
1
REF: 116
7. In
C++, the assignment operator has a(n) ____________________ precedence than any
other arithmetic operator.
ANS: lower
PTS:
1
REF: 108-109
8. The
____________________ manipulator must be included for each occurrence of a
number inserted in the data stream sent to cout.
ANS: field width
PTS:
1
REF: 122
9. To
alter the default justification for a stream of data, you use the ____________________
manipulator.
ANS: setiosflags
PTS:
1
REF: 124
10.
A parameterized manipulator takes ____________________ flags as
input.
ANS: format
PTS:
1
REF: 125
11.
Function ____________________ permits using the same function
name for different arguments of different data types.
ANS: overloading
PTS:
1
REF: 134
12.
In C++, the cmath function named ____________________ is used to
raise a number to a power.
ANS: pow
PTS:
1
REF: 135
13.
In C++, arguments of all trigonometric functions (sin(), cos(),
and so forth) must be in ____________________.
ANS: radians
PTS:
1
REF: 137
14.
In this statement: int (a * b); , int is a(n)
____________________ operator.
ANS: cast
PTS:
1
REF: 138
15.
In C++, a variable or symbolic constant must be
____________________ before it has been used.
ANS: declared
PTS:
1
REF: 154
16.
Programs that detect and respond effectively to unexpected user
input are formally referred to as ____________________ programs.
ANS: robust
PTS:
1
REF: 146
17.
The ____________________ statement puts the computer in a temporary
pause (or wait) state while the user types a value.
ANS: cin
PTS:
1
REF: 144
Chapter 5: Repetition Statements
TRUE/FALSE
1. Loop
structures can evaluate the condition only at the beginning of the repeating
section of code.
ANS:
F
PTS:
1
REF: 236
2. The
do while construct is an example of a posttest loop.
ANS:
T
PTS:
1
REF: 236
3. C++’s
for statement is virtually interchangeable with its while statement.
ANS:
T
PTS:
1
REF: 263
4. Combining
interactive data entry with the repetition capabilities of the while statement
produces adaptable and powerful programs.
ANS: T
PTS:
1
REF: 250
5. As a
general rule, the continue statement is less useful than the break statement.
ANS:
T
PTS:
1
REF: 258
6. The
for statement performs the same functions as the while statement, but uses a
different form.
ANS:
T
PTS:
1
REF: 263
7. The
construction for ( ; count <= 20 ; ) is invalid.
ANS:
F
PTS:
1
REF: 265
8. In
C++, continue produces the same action for both while and for statements.
ANS:
F
PTS:
1
REF: 267
9. Entering
data interactively in a loop is a general technique that’s applicable to for
loops.
ANS:
T
PTS:
1
REF: 275
10.
The do statement is particularly useful in filtering
user-entered input and providing data validation checks.
ANS:
T
PTS:
1
REF: 294
MULTIPLE CHOICE
1. A(n) ____
statement both defines the boundaries containing the repeating section of code
and controls whether the code will be executed.
|
a. |
declaration |
c. |
arithmetic |
|
b. |
selection |
d. |
repetition |
ANS:
D
PTS: 1
REF: 236
2. Three
different forms of repetition statements are provided in C++: while, ____, and
do while.
|
a. |
for |
c. |
switch |
|
b. |
if-else |
d. |
if-else chain |
ANS:
A
PTS:
1
REF: 236
3. In a(n)
____ loop, the condition is tested before any statements in the loop are
executed.
|
a. |
posttest |
c. |
prior |
|
b. |
pretest |
d. |
early-test |
ANS:
B
PTS:
1
REF: 236
4. Both
the ____ and for loop structures are examples of entrance-controlled loops.
|
a. |
while |
c. |
do while |
|
b. |
switch |
d. |
if-else |
ANS:
A
PTS:
1
REF: 236
5. A
loop that evaluates a condition at the end of the repeating section of code is
referred to as a(n) ____ loop.
|
a. |
entrance-controlled |
c. |
exit-controlled |
|
b. |
pretest |
d. |
aftertest |
ANS:
C
PTS:
1
REF: 236
6. ____
loops always execute the loop statements at least once before the condition is
tested.
|
a. |
Pretest |
c. |
entrance-controlled |
|
b. |
Posttest |
d. |
beforetest |
ANS:
B
PTS:
1
REF: 236
7. In a
____ loop, the condition is used to keep track of how many repetitions have
occurred.
|
a. |
pretest |
c. |
variable-condition |
|
b. |
posttest |
d. |
fixed-count |
ANS:
D
PTS:
1
REF: 237
8. In
C++, a ____ loop is constructed using a while statement.
|
a. |
while |
c. |
do |
|
b. |
whereas |
d. |
switch |
ANS: A
PTS:
1
REF: 238
9. A(n)
____ loop is a loop that never ends.
|
a. |
fixed |
c. |
infinite |
|
b. |
controlled |
d. |
finite |
ANS:
C
PTS:
1
REF: 241
10.
The line total = total + num is an example of a(n) ____
statement.
|
a. |
initialization |
c. |
accumulating |
|
b. |
declaration |
d. |
definition |
ANS:
C
PTS:
1
REF: 253
11.
In computer programming, data values used to signal the start or
end of a data series are called ____.
|
a. |
sentinels |
c. |
dummies |
|
b. |
marks |
d. |
interrupts |
ANS:
A
PTS:
1
REF: 256
12.
A(n) ____ statement forces an immediate exit from the switch,
while, for and do-while statements.
|
a. |
exit |
c. |
stop |
|
b. |
break |
d. |
halt |
ANS:
B
PTS:
1
REF: 258
13.
When ____ is encountered in a loop, the next iteration of the
loop begins immediately.
|
a. |
goto |
c. |
resume |
|
b. |
go |
d. |
continue |
ANS: D
PTS:
1
REF: 258
14.
A semicolon with nothing preceding it is also a valid statement,
called the ____ statement.
|
a. |
empty |
c. |
blank |
|
b. |
null |
d. |
void |
ANS:
B
PTS: 1
REF: 259
Comments
Post a Comment