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 | |
|---|---|---|
| 1CASE OF Choice 1: OUTPUT "Start" 2: OUTPUT "Quit" ENDCASE | ACASE was used for a score test with a comparison operator (>=). CASE clauses match fixed values or ranges, so use IF Score >= 50 THEN ... ELSE ... ENDIF. | |
| 2IF Age >= 13 AND Age <= 19 THEN OUTPUT "Teenager" ENDIF | BA menu choice: one variable (Choice) is matched against fixed values, so CASE is the neat choice. | |
| 3A CASE statement can be rewritten as nested IF by testing the same variable against each fixed value in turn. | CDeeply nested IF is used for a menu where one variable is matched against fixed values. This is hard to read and should be a CASE OF Choice statement instead. | |
| 4Nested IF testing one variable for fixed values is easier to read when rewritten as a CASE statement. | DAn age test using relational and logical operators, so IF is the right choice, not CASE. | |
| 5CASE OF Score >= 50: OUTPUT "Pass" OTHERWISE OUTPUT "Fail" ENDCASE | EIF Choice = 1 THEN OUTPUT "Start" ELSE IF Choice = 2 THEN OUTPUT "Quit" ENDIF ENDIF | |
| 6IF Choice = 1 THEN OUTPUT "Start" ELSE IF Choice = 2 THEN OUTPUT "Quit" ELSE IF Choice = 3 THEN OUTPUT "Help" ENDIF ENDIF ENDIF | FCASE OF Day 1: OUTPUT "Mon" 2: OUTPUT "Tue" OTHERWISE OUTPUT "Other" ENDCASE |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
CASE OF — Use CASE OF when one variable is matched against fixed values, like a menu choice. Use IF when you test conditions with <, > or AND/OR, like age or score tests.CASE OF choice
1: OUTPUT "Play"
ENDCASEIF age >= 18 THEN
OUTPUT "Adult"
ENDIFIF score >= 50 AND score < 70 THEN
OUTPUT "Merit"
ENDIFIF choice = 1 THEN OUTPUT "Play"
ELSE OUTPUT "Quit"
ENDIFCASE OF mark
1 TO 4: OUTPUT "Low"
ENDCASE