Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
This IF ... THEN ... ELSE ... ENDIF (7c) worksheet is part of the IGCSE Computer Science 0478 — 7c Pseudocode and Flowcharts 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 | |
|---|---|---|
| 1IF Mark >= 50 THEN OUTPUT "Pass" ELSE OUTPUT "Fail" ENDIF | AIF Answer < 0 OR Answer > 100 THEN Correct ← FALSE ELSE Correct ← TRUE ENDIF | |
| 2ELSE | BIF Age >= 18 THEN OUTPUT "Adult" ELSE OUTPUT "Child" ENDIF | |
| 3Check a range: set Correct to FALSE if Answer is outside 0 to 100, otherwise set it to TRUE | CStarts the statements that run when the IF condition is FALSE; it has no condition of its own | |
| 4ELSE has no condition, so it is written on its own line with nothing after it | DExactly one message is output: Pass when Mark is 50 or more, otherwise Fail | |
| 5IF Score > 10 THEN OUTPUT "High" ELSE Score <= 10 THEN OUTPUT "Low" ENDIF | EThe ENDIF is missing, so the IF ... ELSE structure is never closed. ENDIF must be added after the ELSE branch. | |
| 6IF Answer < 0 OR Answer > 100 THEN Correct ← FALSE ELSE Correct ← TRUE | FELSE has been given a condition and THEN. ELSE never has a condition, so it should just be ELSE on its own line. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
ELSE — Gives the statements that run when the IF condition is FALSE. ELSE has no condition of its own, so exactly one of the two branches (THEN or ELSE) runs. Correct ← FALSE
ELSE
Correct ← TRUEIF Answer < 0 OR Answer > 100
THEN
Correct ← FALSE ELSE
Correct ← TRUE
ENDIF THEN
Correct ← FALSE
ELSE ELSE
OUTPUT "Well done"
ENDIF