Chapter 5 Practice Quiz

docx

School

Ivy Tech Community College, Indianapolis *

*We aren’t endorsed by this school

Course

120

Subject

Computer Science

Date

Jan 9, 2024

Type

docx

Pages

3

Uploaded by MasterBaboon3951

Report
Chapter 5 Practice Quiz 1. 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 2. 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 3. 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. 4. The statements executed within a loop are known collectively as the . a. loop body b. loop controls c. sequences d. sentinels 5. A counter keeps track of . a. the number of times an event has occurred b. the number of machine 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 6. Adding 1 to a variable is also called it. a. digesting b. resetting c. decrementing d. incrementing
7. 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 8. 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 9. When two loops are nested, the loop that is contained by the other is the loop. a. captive b. unstructured c. inner d. outer 10. 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 11. 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 12. A report that lists only totals, with no details about individual records, is a(n) report. a. accumulator b. final c. group d. summary 13. Typically, the value added to a counter variable is . a. 0 b. 1 c. the same for each iteration d. different in each iteration
14. Typically, the value added to an accumulator variable is . a. 0 b. 1 c. the same for each iteration d. different in each iteration 15. 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 16. 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 17. Overriding a user’s entered value by setting it to a predetermined value is known as . a. forcing b. accumulating c. validating d. pushing 18. 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 19. 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 20. 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 therefore obsolete
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help