CSC 101 Quiz 5

Ace your homework & exams now with Quizwiz!

The ____ statement can be used to eliminate the use of certain bool variables in a loop. Select one: a. if b. while c. switch d. break

d. break

A(n) ____-controlled while loop uses a bool variable to control the loop. Select one: a. counter b. sentinel c. flag d. EOF

c. flag

Loop control variables are automatically initialized in a loop. Select one: True False

False

A sentinel-controlled while loop is an event-controlled while loop whose termination depends on a special value. Select one: True False

True

After a break statement executes, the program continues to execute with the first statement after the structure. Select one: True False

True

Assume all variables are properly declared. The output of the following C++ code is 2 3 4 5. n = 1; while (n < 5) { n++; cout << n << " "; } Select one: True False

True

In a counter-controlled while loop, the loop control variable must be initialized before the loop. Select one: True False

True

In the case of the sentinel-controlled while loop, the first item is read before the while loop is entered. Select one: True False

True

Consider the following code. (Assume that all variables are properly declared.) cin >> ch; while (cin) { cout << ch; cin >> ch; } This code is an example of a(n) ____ while loop. Select one: a. sentinel-controlled b. flag-controlled c. EOF-controlled d. counter-controlled

c. EOF-controlled

In a sentinel-controlled while loop, the body of the loop continues to execute until the EOF symbol is read. Select one: True False

False

It is possible that the body of a while loop may not execute at all, but the body of a for loop executes at least once. Select one: True False

False

A loop is a control structure that allows you to repeat a set of statements until certain conditions are met. Select one: True False

True

The control variable in a flag-controlled while loop is a bool variable. Select one: True False

True

The execution of a break statement in a while loop terminates the loop. Select one: True False

True

The function eof returns true if the program has read past the end of the input file. Select one: True False

True


Related study sets

Chapter 14: Care of a patient with a Neurologic disorder exam

View Set

Writing a Persuasive E-mail Assignment

View Set

The Lean StartUp, Identify Your Niche, Finding Your Audience Quiz, Finding Your Passion

View Set

13.1: Polyhedra and Other Solid Shapes

View Set

AP GOV unit 3 mcq (3.1, 3.2, 3.4, 3.5, 3.7, 3.9- 3.13)

View Set

Diagnostic Testing HESI prep- Adult Care

View Set

50 Sophisticated Words You Should Start Using Instead

View Set