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 | |
|---|---|---|
| 1ENDIF ENDIF NEXT i | AOpens three levels of nesting: a WHILE containing a FOR containing an IF, each indented one level further than the one before. | |
| 2WHILE n > 0 DO FOR i <- 1 TO 3 IF i = n THEN | BFOR i <- 1 TO 3 IF i > 1 THEN IF i < 3 THEN OUTPUT i | |
| 3A WHILE containing a FOR containing an IF must be closed in reverse order: ENDIF, then NEXT, then ENDWHILE. | C ENDIF NEXT j ENDWHILE | |
| 4Indent each level of nesting one step further, so the innermost statement sits furthest to the right. | DNEXT i closes the FOR before the outer IF has been closed. The structures overlap instead of nesting. The outer ENDIF must come before NEXT i. | |
| 5FOR i <- 1 TO 5 IF a > 0 THEN IF b > 0 THEN OUTPUT i ENDIF NEXT i ENDIF | EThe outermost WHILE loop is never closed. ENDWHILE is missing after NEXT i. | |
| 6WHILE n > 0 DO FOR i <- 1 TO 3 IF i = n THEN OUTPUT i ENDIF NEXT i | FCloses the inner IF first, then the outer IF, then the FOR loop. This is the reverse of the order they were opened. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
nesting — Putting one structure inside another, three levels deep. Indent each level and close them in reverse order: innermost first, e.g. ENDIF, ENDIF, then NEXT.FOR Day <- 1 TO 7
IF Temp > 20 THEN
IF Rain = 0 THEN ENDIF
NEXT Count
ENDWHILEWHILE Total < 100 DO
FOR Count <- 1 TO 5
IF Mark > 50 THENWHILE Total < 100 DO
FOR Count <- 1 TO 5
IF Mark > 50 THEN ENDIF
ENDIF
NEXT Day