Back to marketplace

Unit 4 - Iteration

No description yet. This curated deck is ready for daily study.

Total cards: 23•Content version: v4•Public deck•Updated: 8/1/2026

Card preview (23)

#1
Front (Question)

iteration statements

Back (Answer)

Change the flow of control by repeating a set of statements zero or more times until a condition is met

#2
Front (Question)

Loop

Back (Answer)

Repetition of statements Repeating a series of steps over & over and over

#3
Front (Question)

Structure of while loop

Back (Answer)

while (/*Boolean expression/*) { //statement one; //statement two; // ... }

#4
Front (Question)

Loop control variable

Back (Answer)

//initialize LCV while (/* check LCV*/) { //statement one; //statement two; //.... //update loop control variable }

#5
Front (Question)

A loop is an infinite loop when

Back (Answer)

the Boolean expression always evaluate to true

#6
Front (Question)

If the Boolean expression evaluates to false initially,

Back (Answer)

the loop body is never executed at all

#7
Front (Question)

Algorithm to sum individual digits given a number

Back (Answer)

Using mod, integer division, and while loop to do so 1 - Given an integer called number 2 - Create a variable for the sum 3 - Use mod to isolate the last digit of the number 4 - add the last digit to sum 5 - use integer division to eliminate the last digit from the number 6 - Repeat while there are still digits 7 - display the sum

#8
Front (Question)

Algorithm to calculate the number of years it would take to reach your goal using Interest

Back (Answer)

1 - Given an integer called numYears 2 - Create a variable for the total 3 - Add total to total multiplied by 10 years 4 - increase year by one and print out yearly balance 5 - Repeat until total reaches 1000 6 - Display numYears

#9
Front (Question)

Algorithm to sum first 10 positive multiples of 4

Back (Answer)

1 - Given an integer called counter 2 - Create a variable for the sum 3 - Add sum to counter multiplied by 4 4- Increase counter by one 5 - Repeat until value reaches 10 6 - Display sum

#10
Front (Question)

for loop header

Back (Answer)

3 parts initialization Boolean expression increment or decrement

#11
Front (Question)

in a for loop, initialization is

Back (Answer)

only executed once before the first Boolean expression evaluation

#12
Front (Question)

In each iteration of a for loop, the increment statement is executed after

Back (Answer)

the entire loop body is executed and before the Boolean expression is evaluated again

#13
Front (Question)

Structure of a for loop

Back (Answer)

for (initialization;Boolean expression; update)’

#14
Front (Question)

a for loop can be rewritten into an

Back (Answer)

equivalent while loop and vice versa

#15
Front (Question)

When statements need to repeat a defined number of time, which type is more appropriate?

Back (Answer)

for loop may be more appropriate as start and end values can be seen on one line

#16
Front (Question)

When repeating statements an x amount of times or based on complex Boolean expression, which type is more appropriate?

Back (Answer)

while loop as while statement isolates the Boolean expression

#17
Front (Question)

When updating to LCV is more complex than a simple increment or decrement, which type is more appropriate?

Back (Answer)

while loop as you can update LCV over a series of statements to make it more readable

#18
Front (Question)

OBOE

Back (Answer)

iteration statement loops one time too many or too few

#19
Front (Question)

Common mistakes made in initialization

Back (Answer)

Should a variable start at 0 or 1

#20
Front (Question)

Common mistakes made in boolean expression

Back (Answer)

Should we use < or <=

#21
Front (Question)

Common mistakes made in updating

Back (Answer)

Should our value increase or decrease by 1 each time

#22
Front (Question)

How to prevent mistakes

Back (Answer)

Test loop with small values THINK

#23
Front (Question)

Algorithm for finding substring within a String

Back (Answer)

ggg