Chapter 4 Self-Quiz

True/False

Indicate whether the statement is true or false.

____1.Both selection and repetition statements allow the programmer to alter the normal sequential flow of control.

____2.The relationship 3 < 4 is always true, therefore the relationship has a value of 0.

____3.The logical operators AND, OR and NOT are used to create more complex relational expressions.

____4.The NOT operator is a binary operator.

____5.Tests for equality of single-precision and double-precision values and variables using the relational operator == are usually reliable.

____6.The if-else statement directs the computer to select between two statements based on the result of a comparison.

____7.All statements contained within a compound statement constitute a single block of code.

____8.if-elsestatements can not contain compound statements.

____9.Boolean values true and false are represented by the integer values 0 and 1 respectively.

____10.C++ has always had a built-in Boolean data type with two Boolean values, true and false.

____11.if-elsestatements can not contain other if-else statements.

____12.An if-else chain is stopped once a true condition is found.

____13.An if-else chain can not be continued indefinitely by repeatedly making the last statement another if-else statement.

____14.Once an entry point has been located by the switch statement further case evaluations will continue.

____15.Using the assignment operator, =, in place of the relational operator, ==, is a commonly made C++ programming error.

Multiple Choice

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

____16.Relational expressions are also called ____.

a. / options / c. / conditions
b. / choices / d. / paths

____17.The value of a relational expression such as hours > 40 depends on the ____ stored in the variable hours.

a. / condition / c. / value
b. / sign / d. / relationship

____18.____ letters is essential in alphabetizing names.

a. / Comparing / c. / Deleting
b. / Capitalizing / d. / Adding

____19.Many ____ numbers cannot be represented exactly in binary form using a finite number of bits.

a. / small / c. / integer
b. / large / d. / decimal

____20.For single-precision and double-precision operands, the general expression operand_1 == operand_2 should be replaced by this condition:

a. / operand_1 – operand_2 < EPSILON
b. / abs(operand_1 – operand_2) < EPSILON
c. / operand_2 – operand_1 < EPSILON
d. / operand_1 – operand_2 >= EPSILON

____21.Using the abs() function requires including the ____ header file.

a. / iostream / c. / cmath
b. / system / d. / math

____22.A(n) ____ statement is a sequence of single statements between braces.

a. / Boolean / c. / compound
b. / conditional / d. / if-else

____23.If age is initialized to equal 18, the statement age == 40 has a value of ____.

a. / 0 / c. / 18
b. / 1 / d. / 30

____24.C++ treats any nonzero value as ____.

a. / true
b. / false
c. / either true or false
d. / None of the above, because you cannot make a general statement about this

____25.Including one or more if statements inside an existing if statement is called a ____ if statement.

a. / compound / c. / nested
b. / complex / d. / chain

____26.In the absence of braces in an if-else statement, each else is associated with the ____ unpaired if.

a. / next / c. / shortest
b. / last / d. / closest

____27.In a C++ program, statement indentation is ____ as far as the compiler is concerned.

a. / required / c. / irrelevant
b. / invalid / d. / standardized

____28.In an if-else chain, the final else is ____.

a. / a default or catch-all case / c. / required
b. / recommended / d. / not used

____29.____ case labels may be contained within a switch statement.

a. / Up to 1 / c. / Up to 100
b. / Up to 10 / d. / Any number of

____30.If break statements are omitted from a switch statement, ____ cases following the matching case value are executed.

a. / no / c. / all
b. / some / d. / two

Chapter 4 Self-Quiz

Answer Section

TRUE/FALSE

1.ANS:TPTS:1REF:137

2.ANS:FPTS:1REF:138

3.ANS:TPTS:1REF:139

4.ANS:FPTS:1REF:140

5.ANS:FPTS:1REF:142

6.ANS:TPTS:1REF:143

7.ANS:TPTS:1REF:148

8.ANS:FPTS:1REF:149

9.ANS:FPTS:1REF:153

10.ANS:FPTS:1REF:153

11.ANS:FPTS:1REF:158

12.ANS:TPTS:1REF:159

13.ANS:FPTS:1REF:160

14.ANS:FPTS:1REF:169

15.ANS:TPTS:1REF:173

MULTIPLE CHOICE

16.ANS:CPTS:1REF:138

17.ANS:CPTS:1REF:139

18.ANS:APTS:1REF:139

19.ANS:DPTS:1REF:142

20.ANS:BPTS:1REF:142

21.ANS:CPTS:1REF:142

22.ANS:CPTS:1REF:146

23.ANS:APTS:1REF:151-152

24.ANS:APTS:1REF:152

25.ANS:CPTS:1REF:158

26.ANS:DPTS:1REF:159

27.ANS:CPTS:1REF:159

28.ANS:APTS:1REF:159

29.ANS:DPTS:1REF:168

30.ANS:CPTS:1REF:169