Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
This Nested and mixed iteration worksheet is part of the VCE Pseudo Code 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 | |
|---|---|---|
| 1WHILE total < 10 DO FOR i FROM 1 TO 3 total ← total + i END FOR END WHILE | ACloses the inner FOR loop first, then the outer WHILE loop | |
| 2END FOR followed by END WHILE | BFOR j FROM 1 TO 5 WHILE total < 20 DO | |
| 3Nesting one loop type inside a different loop type | CThe inner WHILE loop must be closed with END WHILE before END FOR | |
| 4A WHILE loop written entirely inside the body of a FOR loop | DMixed iteration | |
| 5WHILE total < 10 DO FOR i FROM 1 TO 3 total ← total + i ENDFOR END WHILE | EA FOR loop nested inside a WHILE loop | |
| 6FOR i FROM 1 TO 3 WHILE total < 5 DO total ← total + i END FOR | FThe inner loop should close with END FOR, not ENDFOR |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
Mixed iteration — Nesting one loop type inside a different loop type, such as a FOR loop inside a WHILE loopWHILE total < 10 DO
FOR i FROM 1 TO 3WHILE total < 10 DO
FOR i FROM 1 TO 3
total ← total + i
END FORWHILE total < 10 DO
FOR i FROM 1 TO 3
total ← total + i
END FOR
END WHILEFOR j FROM 1 TO 5
WHILE total < 20 DOThe inner loop runs fully for each cycle of the outer loop