Chapter 5: Looping

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

A variable might hold an incorrect value even when it is _______________________. a. the correct data type b. within a required range c. a constant coded by the programmer d. all of the above

d. all of the above

Typically, the value added to an accumulator variable is ___________. a. 0 b. 1 c. the same for each iteration d. different in each iteration

d. different in each iteration

When two loops are nested, the loop that is contained by the other is the _________________ loop. a. captive b. unstructured c. inner d. outer

c. inner

Overriding a user's entered value by setting it to a predetermined value is known as __________________. a. forcing b. accumulating c. validating d. pushing

a. forcing

The statements executed within a loop are known collectively as the ___________________. a. loop body b. loop controls c. sequences d. sentinels

a. loop body

A counter keeps track of ___________________________. a. the number of times an event has occurred. b. the number of machines cycles required by a segment of a program c. the number of loop structures within a program d. the number of times software has been revised

a. the number of times an event has occurred.

When you ___________________, you make sure data items are the correct type and fall within the correct range. a. validate data b. employ offensive programming c. use object orientation d. count loop iterations

a. validate data

Typically, the value added to a counter variable is _______________. a. 0 b. 1 c. the same for each iteration d. different in each iteration

b. 1

Which of the following is a definite loop? a. a loop that executes as long as a user continues to enter valid data b. A loop that executes 1,000 times c. Both of the above d. Neither of the above

b. A loop that executes 1,000 times

Which of the following is an indefinite loop? a. a loop that executes exactly 10 times b. a loop that follows a prompt that asks a user how many repetitions to make and uses the value to control the loop c. Both of the above d. None of the above

b. a loop that follows a prompt that asks a user how many repetitions to make and uses the value to control the loop

The structure that allows you to write one set of instructions that operates on multiple, separate sets of data is the _______________. a. sequence b. loop c. selection d. case

b. loop

To ensure that a user's entry is the correct data type, frequently you _____________________. a. prompt the user to verify that the type is correct b. use a method built into the programming language c. include a statement at the beginning of the program that lists the data types allowed d. all of the above

b. use a method built into the programming language

Most programmers use a for loop _____________________________. a. for every loop they write b. when they know the exact number of times a loop will repeat c. when a loop must repeat many times d. when a loop will not repeat

b. when they know the exact number of times a loop will repeat

Which of the following is not a step that must occur with every correctly working loop? a. Initialize a loop control variable before the loop starts. b. Compare the loop control value to a sentinel during each iteration. c. Set the loop control value equal to a sentinel during each iteration. d. Allow the loop control variable to be altered during each iteration.

c. Set the loop control value equal to a sentinel during each iteration.

A do-while loop ______________________. a. has a body that might never execute b. is a type of pretest loop c. can be replaced by a sequence and a while loop d. is not structured, and therefor obsolete

c. can be replaced by a sequence and a while loop

Adding 1 to a variable is also called ______________________ it a. digesting b. resetting c. decrementing d. incrementing

d. incrementing

After an accumulator or counter variable is displayed at the end of a program, it is best to ________________________. a. delete the variable from the program b. reset the variable to 0 c. subtract 1 from the variable d. none of the above

d. none of the above

When loops are nested, ___________________________. a. they typically share a loop control variable b. one must end before the other begins c. both must be the same type—definite or indefinite d. none of the above

d. none of the above

A report that lists only totals, with no details about individual records, is a(n) _______________________ report. a. accumulator b. final c. group d. summary

d. summary

The loop that frequently appears in a program's mainline logic ________________. a. always depends on whether a variable equals 0 b. is an example of an infinite loop c. is an unstructured loop d. works correctly based on the same logic as other loops

d. works correctly based on the same logic as other loops


संबंधित स्टडी सेट्स

BIO181 Chapter 10 MasteringBiology Homework

View Set

Ch3. Job-Order Costing: Cost Flows & External Reporting

View Set

History 132 - Mid-Term Study Guide

View Set