Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
This Closing nested structures in the right order worksheet is part of the ACARA Digital Technologies Years 7–8 — Algorithms, Flowcharts and Pseudocode journey. Print it as a booklet?
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 | |
|---|---|---|
| 1REPEAT 5 TIMES IF score > 10 THEN SAY "Win" END IF END REPEAT | AThe END IF is missing. The IF block is never closed, which is an error. Add END IF before END REPEAT. | |
| 2END REPEAT | BThe IF is inside the loop, so END IF closes first and END REPEAT closes last. | |
| 3Each IF needs its own END IF, even when the IF sits inside a loop. | CThe end lines are in the wrong order. The innermost block (IF) must be closed first, so END IF goes before END REPEAT. | |
| 4Close the innermost structure first, then the outer one, so the end lines match their opening lines like a stack. | DCloses the REPEAT loop that was opened earlier. It must match a REPEAT line and come after any inner END IF. | |
| 5REPEAT 4 TIMES IF x > 5 THEN SAY "Big" END REPEAT | EREPEAT UNTIL lives = 0 IF hit = true THEN lives ← lives - 1 END IF END REPEAT | |
| 6REPEAT 4 TIMES IF x > 5 THEN SAY "Big" END REPEAT END IF | FREPEAT 3 TIMES IF age >= 13 THEN SAY "Teen" END IF END REPEAT |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
END IF / END REPEAT — Each IF and each REPEAT needs its own end line. Close the innermost block first, so END IF comes before END REPEAT when an IF is inside a loop. A missing end line is an error. SET score TO score + 1
END IF
END REPEAT SET score TO score + 1
END IF
END REPEATIF lives = 0 THEN
SAY "Game over"
END IFREPEAT 3 TIMES
SAY "Hi"
END REPEAT SAY "Done"
END IF
END REPEAT