Cambridge 9618 · International A Level Computer Science · ~14 min read
Notes
Video
Slides
Quiz
Worksheet
INPUT and OUTPUT
Cambridge 9618 uses specific keywords for reading user input and displaying output:
// INPUT reads a value from the user into a variable DECLARE name : STRING DECLARE age : INTEGER INPUT name INPUT age
// OUTPUT displays values to the user OUTPUT"Hello, ", name OUTPUT"Your age is: ", age OUTPUT age + 1// expressions can be used in OUTPUT
Note: Cambridge 9618 uses INPUT (not READ or SCAN) and OUTPUT (not PRINT or WRITE).
Selection — IF...THEN...ELSE...ENDIF
Selection (branching) lets a program choose different paths depending on a condition.
Basic IF
IF age >= 18THEN OUTPUT"Adult" ENDIF
IF...ELSE
IF score >= 50THEN OUTPUT"Pass" ELSE OUTPUT"Fail" ENDIF
Nested IF (chained conditions)
IF score >= 80THEN OUTPUT"A" ELSE IF score >= 60THEN OUTPUT"B" ELSE IF score >= 40THEN OUTPUT"C" ELSE OUTPUT"Fail" ENDIF ENDIF ENDIF
Cambridge 9618 does not have ELIF or ELSEIF — nest IF inside ELSE instead.
Selection — CASE...OF...OTHERWISE...ENDCASE
CASE is used when a single variable can have several discrete values. It is cleaner than deeply nested IFs for this purpose.
CASE OF grade "A" : OUTPUT"Excellent" "B" : OUTPUT"Good" "C" : OUTPUT"Satisfactory" OTHERWISE : OUTPUT"Below standard" ENDCASE
CASE with INTEGER values
DECLARE day : INTEGER INPUT day CASE OF day 1 : OUTPUT"Monday" 2 : OUTPUT"Tuesday" 3 : OUTPUT"Wednesday" 4 : OUTPUT"Thursday" 5 : OUTPUT"Friday" OTHERWISE : OUTPUT"Weekend" ENDCASE
Boolean Operators
Conditions can be combined using Boolean operators to create compound conditions:
AND
TRUE only if both conditions are TRUE. Example: age >= 16 AND age < 18
OR
TRUE if at least one condition is TRUE. Example: grade = "A" OR grade = "B"
NOT
Inverts a boolean: TRUE becomes FALSE. Example: NOT (x = 0)
Using AND / OR in IF conditions
// Compound conditions with AND/OR IF age >= 16AND hasID = TRUETHEN OUTPUT"Access granted" ENDIF
IF score < 0OR score > 100THEN OUTPUT"Invalid score" ENDIF
IF NOT passed THEN OUTPUT"Please resit" ENDIF
Worked Example — Complete Program
// Grade calculator with IF and CASE DECLARE score : INTEGER DECLARE grade : CHAR
OUTPUT"Enter your score (0-100): " INPUT score
IF score < 0OR score > 100THEN OUTPUT"Error: score out of range" ELSE IF score >= 80THEN
grade ← 'A' ELSE IF score >= 60THEN
grade ← 'B' ELSE
grade ← 'C' ENDIF ENDIF CASE OF grade 'A' : OUTPUT"Distinction" 'B' : OUTPUT"Merit" OTHERWISE : OUTPUT"Pass" ENDCASE ENDIF
IF vs CASE — When to Use Each
Use IF when
Use CASE when
Comparing ranges (e.g., score >= 80)
Comparing a single variable against specific discrete values
Complex compound conditions (AND/OR)
The variable has several possible exact values (like menu choices)
Checking different variables in each branch
All branches check the same variable for equality
✅ Correct — CASE syntax
CASE OF choice 1 : OUTPUT "New" 2 : OUTPUT "Load" OTHERWISE : OUTPUT "Exit" ENDCASE
❌ Wrong — missing OTHERWISE/ENDCASE
CASE OF choice 1 : OUTPUT "New" 2 : OUTPUT "Load" // missing OTHERWISE // missing ENDCASE
Exam tip: Cambridge 9618 requires exact syntax. CASE must include OTHERWISE (handles all other values) and must be closed with ENDCASE. IF must always end with ENDIF. Cambridge does not use ELIF — use nested IF...ELSE...IF instead. Each ENDIF closes one IF block.
⚠️ Common Mistakes
Writing ELIF instead of ELSE followed by another IF (Cambridge 9618 has no ELIF)
Forgetting ENDIF — each IF requires its own ENDIF
Forgetting OTHERWISE in CASE — examiners expect it
Forgetting ENDCASE at the end of CASE block
Using PRINT or WRITE instead of OUTPUT
Using READ or SCAN instead of INPUT
Writing IF (age > 18): — no colon after THEN, no brackets required
✅ Notes completed!
▶
Video coming soon
Click slide or press arrow keys to navigate
Worksheet — 2.3.2 Input/Output & Selection
8 questions · Cambridge 9618 standard
Q1Write pseudocode to ask the user for their name, then output "Hello, " followed by their name.[3]
✅ Mark scheme
DECLARE name : STRING [1]; INPUT name [1]; OUTPUT "Hello, ", name [1].
Q2Write an IF...ELSE...ENDIF statement that outputs "Pass" if a score is 50 or above, and "Fail" otherwise.[4]
✅ Mark scheme
IF score >= 50 THEN [1]; OUTPUT "Pass" [1]; ELSE [1]; OUTPUT "Fail"; ENDIF [1].
Q3Write a CASE OF statement to output a word for a number 1–3: 1 = "One", 2 = "Two", 3 = "Three", anything else = "Unknown". Use variable num.[5]
✅ Mark scheme
CASE OF num [1]; 1 : OUTPUT "One" [1]; 2 : OUTPUT "Two"; 3 : OUTPUT "Three" [1]; OTHERWISE : OUTPUT "Unknown" [1]; ENDCASE [1].
Q4What is the difference between AND and OR in Boolean conditions? Give an example of each.[4]
✅ Mark scheme
AND: both conditions must be TRUE for the overall condition to be TRUE [1]; example: IF age >= 16 AND hasID = TRUE THEN [1]. OR: at least one condition must be TRUE [1]; example: IF grade = "A" OR grade = "B" THEN [1].
Q5Identify and correct all errors in this pseudocode: IF score > 80 PRINT "Excellent" ELIF score > 60 PRINT "Good" END[4]
✅ Mark scheme
Errors: PRINT should be OUTPUT [1]; ELIF should be ELSE (Cambridge has no ELIF) [1]; missing THEN after IF condition [1]; END should be ENDIF (or two ENDIFs for nested IF) [1]. Corrected: IF score > 80 THEN; OUTPUT "Excellent"; ELSE; IF score > 60 THEN; OUTPUT "Good"; ENDIF; ENDIF.
Q6Explain when CASE is more suitable than IF for selection. Give one scenario where IF must be used instead of CASE.[3]
✅ Mark scheme
CASE is more suitable when a single variable is compared against several specific discrete values (e.g., menu choice 1, 2, 3, 4) — cleaner and more readable than nested IF [1]; IF must be used when conditions involve ranges (e.g., score >= 80) [1], compound conditions with AND/OR [1], or comparing different variables in different branches [1]. (Award 3 max.)
Q7Write a FUNCTION called CountChar that takes a STRING and a CHAR as parameters and returns the number of times the character appears in the string. Show a call that counts how many times 'a' appears in "banana".[5]
Q8Explain the difference between string concatenation and string conversion. Write pseudocode to convert the INTEGER 42 to the STRING "42" and then concatenate it with " is the answer" to produce "42 is the answer".[4]
✅ Mark scheme
Concatenation joins strings together — 1 mark; conversion changes a value from one type to another (e.g. INT to STRING) — 1 mark; NUM_TO_STR(42) or INT_TO_STRING(42) produces "42" — 1 mark; result ← NUM_TO_STR(42) & " is the answer" produces "42 is the answer" — 1 mark.
Topic Quiz
Question 1 of 10
You scored
out of 10
Card 1 of 6
Click to reveal definition
🎉
All cards reviewed!
Term
Definition
🎯
Mini Test — 2.3.2 Input/Output & Selection
10 questions · 10 marks · 10 minutes
⏱ 10:00
Section A — Multiple Choice [5 marks]
Q1In Cambridge 9618, which keyword reads a value from the user?
Q2Which keyword ends an IF block in Cambridge 9618?
Q3What does the NOT operator do?
Q4In Cambridge 9618, what handles the default case in a CASE statement?
Q5x = 10, y = 5. What does (x > 8 AND y < 3) evaluate to?
Section B — Short Answer [5 marks]
Q6Write pseudocode to input a temperature and output "Hot" if it is above 30, "Cold" if below 10, and "Comfortable" otherwise.
Mark schemeDECLARE temp : REAL (or INTEGER) [1]; INPUT temp [1]; IF temp > 30 THEN OUTPUT "Hot" [1]; ELSE IF temp < 10 THEN OUTPUT "Cold" ELSE OUTPUT "Comfortable" ENDIF ENDIF [1]. ENDIF/ENDCASE each needed [1].
Q7State one situation where CASE is preferred over nested IF statements.
Mark schemeCASE is preferred when a single variable is compared against multiple specific discrete values (e.g., menu option 1, 2, 3) — it is more readable and less prone to missing ENDIF errors [1].
Q8Explain why Cambridge 9618 uses ELSE followed by a nested IF rather than ELIF.
Mark schemeCambridge 9618 pseudocode does not include an ELIF keyword [1]; to check multiple conditions in sequence, the programmer writes ELSE followed by another IF statement (nested IF), which must then be closed with its own ENDIF [1].
Q9What is wrong with: IF age > 18 AND < 65 THEN? Write the correct version.
Mark schemeError: the second comparison omits the variable name — < 65 is incomplete [1]; correct: IF age > 18 AND age < 65 THEN [1]. Both sides of AND must be complete boolean expressions.
Q10What are the Cambridge 9618 keywords for reading user input and displaying output? State what is WRONG about using PRINT and READ.
Mark schemeCambridge 9618 uses INPUT for reading user input and OUTPUT for displaying values [1]; PRINT and READ are not Cambridge 9618 keywords — using them in pseudocode answers on Cambridge exam papers will not be accepted [1].