Chapter 5 (Repetition Structures)

Description

Computer Science Flashcards on Chapter 5 (Repetition Structures), created by Andrew Lewis on 13/12/2020.
Andrew Lewis
Flashcards by Andrew Lewis, updated more than 1 year ago
Andrew Lewis
Created by Andrew Lewis over 3 years ago
8
0

Resource summary

Question Answer
A _____-controlled loop uses a true/false condition to control the number of times that it repeats. Condition
A _____-controlled loop repeats a specific number of times. Count
Each repetition of a loop is known as an _____. Iteration
The "While" loop is a _____ type of loop. Pretest
The "Do-While" loop is a _____ type of loop. Posttest
The "For" loop is a _____ type of loop. Pretest
An _____ loop has no way of ending and repeats until the program is interrupted. Infinite
A _____ loop always executes at least once. Posttest
A _____ 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
A _____ causes a statement or set of statements to execute repeatedly. Repetition Structure (Loop)
Both "_____" and "_____" lops cause a statement or set of statements to repeat as long as a condition is true. While / Do-While
The "_____" loop causes a statement or set of statements to repeat until a condition is true. Do-Until
True/False: Modules can be called from statements in the body of a loop. This actually often improves the code's design. True
A _____ loop means that it tests its condition before performing an iteration. Pretest
What 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.
A _____ stores the number of iterations that it has performed within a count-controlled loop. Counter Variable (Counter)
Using the counter variable, the loop typically performs the following three actions: Initialization, Test, and Increment
To _____ a variable means to increase its value. Increment
The 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
Before 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
The amount by which the counter variable is incremented in a "For" loop is known as the _____. Step Amount
True/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
To _____ a variable means to decrease its value. Decrement
True/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.
True/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
A _____ 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
What 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.
Should 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.
Why 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.
A _____ is a loop that is inside another loop. Nested Loop
True/False: In a nested loop, an inner loop goes through all of its iterations for every single iteration of an outer loop. True
True/False: In a nested loop, inner loops complete their iterations slower than outer loops. False: Inner loops complete their iterations faster than outer loops.
True/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
Show full summary Hide full summary

Similar

TOEFL English Vocab (A - M)
Ali Kane
Random German A-level Vocab
Libby Shaw
Vocabulary Words
Jenna Trost
TOEFL English Vocabulary (N - Z)
Ali Kane
L'environnement
Bryony Whitehead
TOEFL Vocabulary
aliking
French 1A Vocab
Jade Allatt
10 animals in spanish
Jlaal Mohammed
TOEFL Vocabulary Test
Ali Kane
French 1B Vocab (numbers)
Jade Allatt
French 1D Vocab
Jade Allatt