Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1Decision diamond: Count <= 5 ? placed before the loop body | AAfter the body runs, the flow returns to the condition so it can be tested again. | |
| 2Arrow from the end of the loop body back up to the decision diamond | BThere is no arrow from the end of the body back to the decision, so the loop cannot repeat and the body only ever runs once. | |
| 3The Yes path from the decision runs the loop body, then returns to the decision | CCount <= 5 ? --No--> OUTPUT "Finished" | |
| 4The No path leaves the loop and continues to the next step of the algorithm | DCount <= 5 ? --Yes--> OUTPUT Count --> Count <- Count + 1 --> back to Count <= 5 ? | |
| 5Start --> Count <- 1 --> OUTPUT Count --> Count <- Count + 1 --> Count <= 5 ? --Yes--> back to OUTPUT Count | EThis is the test of a WHILE loop. It is checked first, so the body may run zero times if the condition is false at the start. | |
| 6Count <= 5 ? --Yes--> OUTPUT Count --> Count <- Count + 1 --> OUTPUT "Done" | FThe body is placed before the decision, which draws a REPEAT ... UNTIL style loop. The body must run at least once, but a WHILE body may run zero times. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
WHILE condition DO — In a flowchart the decision comes first. Yes runs the body and an arrow returns to the decision. No leaves the loop to the next step. The body may run zero times.WHILE Count <= 5 DO
OUTPUT Count
ENDWHILEWHILE Count <= 5 DO
Count ← Count + 1
ENDWHILEDecision: Count <= 5?
Yes: body, then arrow back to the decision
No: go to next stepDecision: Total < 20?
No: leave the loop
Yes: run the bodyCount ← 6
WHILE Count <= 5 DO
// body runs 0 times