1/7
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
What is a while loop used for in C++?
A general-purpose loop that repeats as long as a condition is true.
When does a while loop check its condition?
Before each iteration (pre-test loop).
What is a do-while loop in C++?
A loop that executes its body at least once before testing the condition.
Why is a do-while loop good for repeating a process?
Because the loop body always executes once before checking the condition, making it ideal for menu-driven or user-input programs.
What is the general structure of a for loop?
for (initialization; test; update) — initialization runs once, the test is checked each iteration, and the update runs after each loop body execution.
When is a for loop most useful?
When the number of iterations is known or easily controlled.
When is a while loop most useful?
When the number of iterations is unknown and depends on a condition.
When is a do-while loop most useful?
When you need the loop body to run at least once before checking the condition.