Karteikarten
Chapter 5 (Repetition Structures)
Karten in diesem Stapel (33)
- 1A _____-controlled loop uses a true/false condition to control the number of times that it repeats.Condition
- 2A _____-controlled loop repeats a specific number of times.Count
- 3Each repetition of a loop is known as an _____.Iteration
- 4The "While" loop is a _____ type of loop.Pretest
- 5The "Do-While" loop is a _____ type of loop.Posttest
- 6The "For" loop is a _____ type of loop.Pretest
- 7An _____ loop has no way of ending and repeats until the program is interrupted.Infinite
- 8A _____ loop always executes at least once.Posttest
- 9A _____ is a special value that signals when there are no more items from a list of items to be processed. This value cannot be mistaken as an item from the list.Sentinel
- 10A _____ causes a statement or set of statements to execute repeatedly.Repetition Structure (Loop)
- 11Both "_____" and "_____" lops cause a statement or set of statements to repeat as long as a condition is true.While / Do-While
- 12The "_____" loop causes a statement or set of statements to repeat until a condition is true.Do-Until
- 13True/False: Modules can be called from statements in the body of a loop. This actually often improves the code's design.True
- 14A _____ loop means that it tests its condition before performing an iteration.Pretest
- 15What is the difference between a "Do-While" loop and a "Do-Until" loop?A "Do-While" loop iterates while a condition is true. When the condition is false, the "Do-While" loop stops. A "Do-Until" loop iterates until a condition is true. When the condition is true, the "Do-Until" loop stops.
- 16A _____ stores the number of iterations that it has performed within a count-controlled loop.Counter Variable (Counter)
- 17Using the counter variable, the loop typically performs the following three actions:Initialization, Test, and Increment
- 18To _____ a variable means to increase its value.Increment
- 19The count-controlled loop _____ the counter variable by comparing it to a maximum value. If the counter variable is less than or equal to the maximum value, the loop iterates. If the counter is greater than the maximum value, the program exits the loop.Tests
- 20Before the count-controlled loop begins, the counter variable is _____ to a starting value. The starting value that is used will depend on the situation.Initialized
- 21The amount by which the counter variable is incremented in a "For" loop is known as the _____.Step Amount
- 22True/False: Most programming languages provide a way to change the step amount. This gives you the ability to increment the counter variable by any value you wish.True
- 23To _____ a variable means to decrease its value.Decrement
- 24True/False: In most situations, it's best to use the "For" statement to write a count-controlled loop.True: You can use a count-controlled "While" loop, but a "For" loop is better.
- 25True/False: If you forget to increment the counter variable in a count-controlled "While" loop, the loop will iterate an infinite number of times.True
- 26A _____ is a sum of numbers that accumulates with each iteration of a loop. The variable used to keep it is called an _____.Running Total / Accumulator
- 27What two key elements are used in programs to calculate the total of a series of numbers?A loop that reads each number in the series. / A variable that accumulates the total of the numbers as they are read.
- 28Should an accumulator be initialized to any specific value? Why or why not?Yes, it should be initialized with the value 0. This is because values are added to the accumulator by a loop. If the accumulator doesn't start at the value 0, it will not contain the correct total of the numbers that were added to it when the loop ends.
- 29Why should you take care to choose a unique value as a sentinel?A sentinel value must be unique enough that it will not be mistaken as a regular value in the list.
- 30A _____ is a loop that is inside another loop.Nested Loop
- 31True/False: In a nested loop, an inner loop goes through all of its iterations for every single iteration of an outer loop.True
- 32True/False: In a nested loop, inner loops complete their iterations slower than outer loops.False: Inner loops complete their iterations faster than outer loops.
- 33True/False: In a nested loop, to get the total number of iterations of a nested loop, multiply the number of iterations of all loops.True
Informationen
- Beschreibung
- Der Nutzer hat seine Fachbereichs-Information gelöscht. Karteikarten am Chapter 5 (Repetition Structures), erstellt von Gelöschter Nutzer am 12/01/2021.
- Erstellt von
- Gelöschter Nutzer · Jan 2021
- Aktualisiert
- 12 Jan 2021
- Aufrufe
- 15
- Tags
- Verlauf
-
- Erstellt von Andrew Lewis · 13 Dez 2020
- Kopiert von Andrew Lewis · 12 Jan 2021
- Bewertung