1/11
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What do loops allow you to do in programming?
Execute the same code multiple times or repeat a routine until a stopping condition is met.
Why are loops useful?
They allow repetition without duplicating code.
What must loops define?
The actions to repeat and how they are repeated.
What is a stopping condition in a loop?
A condition that, once met, ends the loop.
What is a while loop used for?
To repeat an action while a condition is true.
How is a while loop similar to an if statement?
Both check if a condition is true, but a while loop repeats as long as the condition remains true.
When should you use a while loop?
When you don't know how many times a loop needs to run.
What is a for loop used for?
To repeat a set of instructions a known number of times.
What does a for loop communicate?
When to start, how many times to repeat, and what to do after each repetition.
When should you use a for loop?
When the number of repetitions is known ahead of time.
What is a for-each loop used for?
To perform an action on each item in a list.
Why use a for-each loop?
It simplifies code when working with collections of items like lists.