ITPEC IP April 2021 Question 6
Among the program control structures, which of the following is classified as a “while-type” loop structure?
Explanation
The flowchart whose condition comes first and whose process loops back above the condition — a while-type loop tests before each pass.
In (d) control reaches the Condition diamond first. While the condition holds, the Process below it runs and the line returns to above the diamond to test again; when it fails, control leaves by the right corner. The test comes before the body, so the body may run zero times.
Answer (d)
Why not others:
- •(a) — each branch of the condition leads to its own Process and the lines merge below; nothing returns upward, so it is a two-way selection (if–then–else)
- •(b) — the Process runs first and the Condition after it sends control back; this is a post-test loop (repeat-until / do-while), whose body always runs at least once
- •(c) — one branch runs a Process, the other skips it, and both continue downward; a one-way selection (if–then) with no repetition
Key rule: A loop has a line going back up; if the condition sits before the body it is while-type (pre-test, zero or more passes), if after it is until-type (post-test, one or more passes).
Algorithm and Programming · AI-written, may contain errors
This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official IP past-paper collection or Report an issue.