Chapter 5 Looping REVIEW QUESTIONS 1. The structure that allows you to write one set of instructions that operates on multiple, separate sets of data is the _____________________ structure. a. b. c. d. 2. The loop that frequently appears in a program's mainline logic ______________________ . a. b. c. d. 3. digesting resetting decrementing incrementing Which of the following is a definite loop? a. b. c. d, 8. the number of times an event has occurred the number of machine cycles required by a segment of a program the number of loop structures within a program the number of times software has been revised. Adding 1 to a variable is also called ________________________________ it. a. b. c. d. 7. loop body loop controls sequences sentinels A counter keeps track of __________________________ . a. b. c. d. 6. Initialize a loop control variable before the loop starts. Set the loop control value equal to a sentinel during each iteration. Compare the loop control value to a sentinel each iteration. Alter the loop control variable during each iteration. The statements executed within a loop are known collectively as the__________________ . a. b. c. d. 5. always depends on whether a variable equals 0 works correctly based on the same logic as other loops is an unstructured loop is an example of an infinite loop Which of the following is not a step that must occur with every correctly working loop? a. b. c. d. 4. sequence selection loop case a loop that executes as long as a user continues to enter valid data a loop that executes 1000 times both of the above none of the above Which of the following is an indefinite loop? a. b. c. d. a loop that executes exactly 10 times a loop that follows a prompt asking a user how many repetitions to make and uses that value to control the loop both of the above none of the above 9. When you decrement a variable, you _________________________ . a. b. c. d. 10. When two loops are nested, the loop that is contained by the other is the __________________ loop. a. b. c. d. 11. 0 1 10 100 Typically, the value added to an accumulator variable is __________________ . a. b. c. d. 16. accumulator final summary detailless Typically, the value added to a counter variable is _______________________ . a. b. c. d. 15. for every loop they write when a loop will not repeat when they do not know the exact number of times a loop will repeat when they know the exact number of times a loop will repeat A report that lists only totals, with no details about individual records, is a(n) ____________ report. a. b. c. d. 14. they typically share a loop control variable one must end before the other begins both must be the same type - definite or indefinite none of the above Most programmers use a for loop ____________________________ . a. b. c. d. 13. captive unstructured inner outer When loops are nested, _____________________ . a. b. c. d. 12. set it to 0 reduce it by one-tenth subtract 1 from it remove it from a program 0 1 the same for each iteration different in each iteration After an accumulator or counter variable is displayed at the end of a program, it is best to ______________ . a. b. c. d. delete the variable from the program reset the variable to 0 subtract 1 from the variable none of the above 17. When you _______________ , you make sure data items are the correct type and fall within the correct range. a. b. c. d. 18. Overriding a user's entered value by setting it to a predetermined value is known as _________________ . a. b. c. d. 19. forcing accumulating validating pushing To ensure that a user’s entry is the correct data type, frequently you . a. b. c. d. 20. validate data employ offensive programming use object orientation count loop iterations prompt the user, asking if the user is sure the type is correct use a method built into the programming language include a statement at the beginning of the program that lists the data types allowed all of the above Variables might hold incorrect values even when they are _______________________ . a. b. c. d. the correct data type within a required range coded by the programmer rather than input by a user all of the above