C++ Unit 5 Test (Control Structures II)

¡Supera tus tareas y exámenes ahora con Quizwiz!

Which of the following is a Fibonacci sequence? a. 1,1,2,3,5,8 b. 1,2,4,8,16,32 c. 1,1,2,3,5,80,1,0,2,0,1 d. 0,1,2,4,16,25

a. 1,1,2,3,5,8

Which of the following is the general form of the do...while statement? a. do statement while (expression); b. do while statement (expression); c. do expression while (statement); d. do (statement); while expression

a. do statement while (expression);

Putting one control structure inside another is called ____. a. nesting b. looping c. indexing d. sequencing

a. nesting

A _____ is a special value that marks the end of the input data. a. sentinel b. trigger c. switch d. constant

a. sentinel

The _____ loop is a pretest loop. a. while b. indexed c. switch d. do...while

a. while

The function rand() is defined in the header file ____. a. cmath b. cstdlib c. iostream d. iomanip

b. cstdlib

The primary purpose of the ____ loop is to simplify the writing of counter-controlled loops. a. sentinel b. for c. do-while d. nested

b. for

In the statement, while (cin), the variable cin acts as the ____. a. counter b. loop control variable c. sentinel d. index

b. loop control variable

When a program reads past the end of the input file, the expression ____ becomes false. a. eof.infile() b. infile.!eof c. !infile.eof() d. infile(eof)

c. !infile.eof()

The _____ statement is an effective way to avoid extra variables to control a loop andproduce elegant code. a. switch b. continue c. break d. skip

c. break

When the ____ statement executes in a repetition structure, it immediately exits from the structure. a. exit b. do c. break d. continue

c. break

The function time is defined in the header file ____. a. iomanip b. cmath c. ctime d. cstdlib

c. ctime

The ____ loop is a posttest loop. a. indexed b. for c. do...while d. while

c. do...while

The most common error associated with loops is a(n) _____ error. a. bounds b. infinite loop c. off-by-one d. syntax

c. off-by-one

Which of the following statements is TRUE? a. A for loop executes indefinitely if the loop condition is always false. b. C++ does not allow you to use fractional values for loop control variables that are real numbers. c. In a for statement, if the loop condition is omitted, it is assumed to be false. d. If the loop condition in a for loop is initially false, the loop body does not execute.

d. If the loop condition in a for loop is initially false, the loop body does not execute.

When the ____ statement executes in a repetition structure, it skips the remaining statements in the loop and proceeds with the next iteration of the loop. a. exit b. break c. do d. continue

d. continue

The C++ eof function is a member of the data type ____. a. file b. cstdlib c. iomanip d. istream

d. istream

Which of the following is the syntax for using the eof function? a. eof().istreamVar b. istreamVar().eof c. istream.eof() d. istreamVar.eof()

d. istreamVar.eof()

A semicolon at the end of a for statement _____ the for loop. a. repeats b. executes c. resets d. terminates

d. terminates

In a for structure, the _____ statement is executed after the continue statement, and before the loop condition executes. a. end b. repeat c. break d. update

d. update


Conjuntos de estudio relacionados

#14 - Chapter 5: Culturally Respectful Care

View Set

confidence intervals and t-distribution

View Set