Revision Notes
Cambridge A Level Computer Science (9618): Programming – Revision Notes
Revision notes on constants, operators, built-in functions, IF and CASE, the three loop types, procedures, functions and parameters for Cambridge 9618.
- Subject
- Computer Science
- Level
- AS LEVEL
- Topic
- Topic 11: Programming
- Author
- Marlbridge Academic Team
- Updated
- Reviewed by
- Harris Khan (what this means)
Aligned to Cambridge A Level Computer Science (9618), 2026. Official specification .
Syllabus page (what it covers and how it is assessed): Cambridge A Level Computer Science.
Syllabus points this page covers
9618 (AS Level)
- 11 Programming (whole topic)
- 11.1 Programming Basics
- 11.2 Constructs
- 11.3 Structured Programming
Found an error? Report a correction.
Need help with this topic? Request a free trial class for A Level Computer Science (9618).
Topic 11 Programming covers writing Cambridge pseudocode: declaring constants and variables, using operators and built-in functions, choosing between IF and CASE, choosing the right loop, and structuring a program into procedures and functions with parameters passed by value or by reference. In Cambridge International AS & A Level Computer Science 9618 it is examined in Paper 2, which is marked against the 9618 Pseudocode Guide and the function Insert given in the exam.
Related: Programming study guide · Programming practice questions · Computer Science course hub
Syllabus coverage
| Section | Candidates should be able to |
|---|---|
| 11.1 | Implement and write pseudocode from a design given as a flowchart or structured English |
| 11.1 | Write pseudocode for declaring and initialising constants, declaring variables, assignment, and expressions with arithmetic or logical operators, keyboard input and console output |
| 11.1 | Use built-in functions and library routines (those not in the pseudocode guide, and all string functions, will be given) |
| 11.2 | Use pseudocode for IF with ELSE and nested IF; CASE; count-controlled, post-condition and pre-condition loops |
| 11.2 | Justify why one loop structure suits a problem better than the others |
| 11.3 | Define and use a procedure and a function; explain where each is appropriate |
| 11.3 | Use parameters, passed by value or by reference |
| 11.3 | Use the terminology: procedure/function header, interface, parameter, argument, return value |
| 11.3 | Write efficient pseudocode |
Declarations and assignment
CONSTANT VatRate = 0.2
DECLARE Quantity : INTEGER
DECLARE Price, Total : REAL
DECLARE Name : STRING
Quantity ← 3
Total ← Quantity * Price * (1 + VatRate)
- A constant’s value is fixed when it is declared and cannot be changed while the program runs. Using one makes code easier to read and to update (change it in one place). Only a literal value may be used.
- Assignment uses
←. Input withINPUT Name; output withOUTPUT "Hello ", Name.
Operators
| Type | Operators | Notes |
|---|---|---|
| Arithmetic | + - * / |
/ always gives a REAL result |
| Integer | DIV, MOD |
17 DIV 5 = 3; 17 MOD 5 = 2 |
| Relational | = <> < > <= >= |
Result is BOOLEAN |
| Logical | AND OR NOT |
Use brackets to show the order |
| String | & |
Concatenation: “Ali” & “ “ & “Khan” |
Built-in functions (examples from the pseudocode guide)
| Function | Returns | Example |
|---|---|---|
LENGTH(s) |
Number of characters | LENGTH(“Happy Days”) = 10 |
MID(s, x, y) |
y characters starting at position x | MID(“ABCDEFGH”, 2, 3) = “BCD” |
RIGHT(s, x) |
Rightmost x characters | RIGHT(“ABCDEFGH”, 3) = “FGH” |
UCASE(c) / LCASE(c) |
Upper / lower case of a character | UCASE(‘h’) = ‘H’ |
INT(x) |
Integer part of a real | INT(27.5415) = 27 |
RAND(x) |
Random REAL from 0 up to (not including) x | RAND(87) might give 35.43 |
RAND takes one parameter; June 2025 examiners saw it given two. A random whole number from 1 to 6 is INT(RAND(6)) + 1.
Selection
IF Mark >= 70 THEN
Grade ← 'A'
ELSE
IF Mark >= 50 THEN
Grade ← 'B'
ELSE
Grade ← 'U'
ENDIF
ENDIF
CASE OF Choice
1 : CALL AddItem()
2 : CALL RemoveItem()
3 TO 5 : OUTPUT "Not available yet"
OTHERWISE : OUTPUT "Invalid choice"
ENDCASE
Use CASE when one variable is compared with several fixed values or ranges; cases are tested in order and only the first match runs. Use IF for conditions on different variables or complex Boolean expressions.
Which loop should you use?
| Loop | Pseudocode | Condition tested | Use when |
|---|---|---|---|
| Count-controlled | FOR i ← 1 TO n … NEXT i |
Number of repetitions fixed by the bounds | The number of repetitions is known before the loop starts |
| Post-condition | REPEAT … UNTIL condition |
After the body, so the body runs at least once | The body must run at least once, e.g. input validation |
| Pre-condition | WHILE condition … ENDWHILE |
Before the body, so it may run zero times | The loop may not need to run at all, e.g. reading a file that may be empty |
A REPEAT loop stops when its condition becomes TRUE; a WHILE loop stops when its condition becomes FALSE.
Procedures and functions
| Procedure | Function | |
|---|---|---|
| Returns a value? | No (may change BYREF parameters) | Yes, exactly one, with RETURN |
| Called by | CALL ProcName(args) as a statement |
Use in an expression, e.g. Total ← Total + Area(L, W) |
| Use when | A task is carried out, such as outputting a menu | A single value is calculated |
PROCEDURE SwapValues(BYREF A : INTEGER, B : INTEGER)
DECLARE Temp : INTEGER
Temp ← A
A ← B
B ← Temp
ENDPROCEDURE
FUNCTION Area(Length : REAL, Width : REAL) RETURNS REAL
RETURN Length * Width
ENDFUNCTION
| Term | Meaning |
|---|---|
| Header | The first line, giving the identifier, parameters with their types, and (for a function) the return type |
| Interface | The information needed to use a module: its name, the parameters with their data types and order, and the return type |
| Parameter | A variable in the header that receives a value when the module is called |
| Argument | The actual value or variable passed in the call |
| Return value | The value a function sends back to replace the call |
| By value (BYVAL) | A copy of the argument is passed; changes inside the module do not affect the caller (the default) |
| By reference (BYREF) | The address of the argument is passed; changes inside the module change the caller’s variable |
Parameters should not be passed by reference to a function.
Worked example: choosing a loop and writing efficient code
Input a PIN until it has exactly 4 characters, then output a greeting.
DECLARE Pin : STRING
REPEAT
OUTPUT "Enter a 4-digit PIN"
INPUT Pin
UNTIL LENGTH(Pin) = 4
OUTPUT "PIN accepted"
REPEAT suits this because the PIN must be input at least once and the number of attempts is not known. Efficiency points: the length is checked once per input, and there is no separate input before the loop and repeated inside it.
Common mistakes and exam traps
- OUTPUT where a function must RETURN its value (in every series June 2024 to June 2025).
- Using
+to join strings instead of&. - Reserved words or built-in function names used as identifiers.
- INPUT of a value that is already passed in as a parameter (June 2024 to June 2025).
- Treating a CASE structure as if every matching case runs; only the first does.
- Declaring an average as INTEGER (June 2025).
/gives a REAL. - Using CALL with a function; CALL is only for procedures.
Frequently asked questions
What is the difference between a parameter and an argument?
The parameter is the name in the module’s header; the argument is the value supplied when the module is called. In CALL Greet("Ola"), “Ola” is the argument and the parameter might be Name.
When must I use BYREF? When the procedure needs to change the caller’s variable, for example swapping two values or returning more than one result from a procedure.
What makes pseudocode efficient? No unnecessary repetition (use loops and modules), loops that stop as soon as the result is known, and calculations moved out of loops when they do not change inside them.
Official syllabus
Cambridge International AS & A Level Computer Science 9618, syllabus for 2026 and syllabus for 2027, 2028 and 2029, Topic 11 (11.1 to 11.3), with syntax from the Cambridge 9618 Pseudocode Guide for Teachers. Examiner points are summarised on our 9618 past papers page.
Get free revision emails (optional)
Occasional emails with practice questions, worked explanations and links to free resources for the qualification and subjects you choose. No spam, and you can unsubscribe from any email. The free tools on this site never need an email.
Related resources
-
Study guides
Cambridge A Level Computer Science (9618): Programming – Study Guide
AS study guide to variables, constants, selection, iteration, string handling, procedures, functions and parameters for Cambridge Computer Science 9618.
Computer Science · Cambridge · AS Level
Read guide -
Practice questions
Cambridge A Level Computer Science (9618): Programming – Practice Questions
Pseudocode questions with answers on constants, operators, string functions, IF, CASE, loop choice, procedures, functions and BYREF for Cambridge AS 9618.
Computer Science · Cambridge · AS Level
Try questions -
Practice questions
Cambridge A Level Computer Science (9618): Security – Practice Questions
Paper 3-style questions with answers on symmetric and asymmetric encryption, quantum cryptography, TLS, certificates and signatures for Cambridge 9618.
Computer Science · Cambridge · A Level
Try questions
Related articles
-
teaching
A Level tuition in Dubai: Cambridge or Pearson Edexcel International A Level?
Schools in Dubai and Abu Dhabi teach either Cambridge International AS & A Level or Pearson Edexcel International A Level. How the two are structured, why it matters for tuition, and how online classes from Lahore work.
9 October 2026
-
curriculum guides
Choosing subjects at IGCSE and A Level
How subject choices at 14 and 16 affect university options later, and how to keep pathways open without overloading a timetable.
28 July 2026
Studying this with a teacher
Working through Computer Science AS LEVEL?
This page is free and stays free. If you would rather be taught it, Marlbridge runs Computer Science classes one-to-one and in small groups of up to 15, online in your own time zone. The first trial class is free. WhatsApp replies within an hour (8am–11pm Pakistan time, every day); email the same day.
Cambridge Computer Science teachers at Marlbridge