ISDS 505 Midterm 1 Chapter 5 Loops Terms (with 100% Errorless Solutions)
A structure that allows repeated execution of a block statement is called a correct answers loop The body of a while loop can consist of either: correct answers a single statement or a block of statements within curly braces A loop that never ends is called a correct answers infinite loop Which of the following is not required of a loop control variable in a correctly working loop? a. It is reset to its initial value before the loop ends b. It is initialized before the loop starts. c. It is tested. d. it is altered in the loop body. correct answers a. It is reset to its initial value before the loop ends. A while loop with an empty body contains no correct answers statements A loop for which you do not know the number of iterations when you write it is called an correct answers indefinite loop What is the major advantage of using a for loop instead of a while loop? a. With a for loop, it is impossible to create an infinite loop. b. The loop control variable is initialized, tested, and altered all in one place. c. It is the only way to achieve an indefinite loop. d. Unlike with a while loop, the execution of multiple statements can depend on the test condition. correct answers b. The loop control variable is initialized, tested, and altered all in one place. A for loop statement must contain: a. two semicolons b. three commas c. four dots d. five pipes correct answers a. two semicolons In a for statement, the section before the first semicolon executes how many times? correct answers once The three sections of the for loop are most commonly used for _____, ______, and _____ the loop control variable correct answers initializing, testing, and incrementing Which type of loop is the most convenient to use if the loop body must always execute at least once? correct answers a do loop
Información del documento
- Subido en
- 5 de abril de 2024
- Número de páginas
- 3
- Escrito en
- 2023/2024
- Tipo
- Examen
- Contiene
- Preguntas y respuestas