Syllabus: Cambridge Pseudocode
1Conditional statements
2Loops
3Common operations
5String manipulation
6Text file handling
7Procedures and functions
8Two-dimensional arrays and records
1.1 Free
IF THEN ELSE
One or two outcomes.
The IF structure
IF condition THEN
statements when TRUE
ELSE
statements when FALSE
ENDIFThe ELSE part is optional.
Worked example: positive, negative or zero
INPUT n
IF n > 0 THEN
OUTPUT "positive"
ELSE
IF n < 0 THEN
OUTPUT "negative"
ELSE
OUTPUT "zero"
ENDIF
ENDIFCommon mistakes
- Forgetting ENDIF.
- Using = when you mean to compare. In Cambridge pseudocode both assignment and comparison are written carefully: assignment uses <-, comparison uses =.
Practice tasks
- 1Output "pass" if a mark is 40 or more.
- 2Output the largest of three numbers.