Programming
Cambridge O Level Computer Science 2210 Topic 8 revision chapter covering programming concepts, arrays and file handling entirely in the current Cambridge pseudocode of the version 5 syllabus. Topic 8.1 covers declaring and using variables and constants, the five basic data types INTEGER, REAL, CHAR, STRING and BOOLEAN with their literal forms, INPUT and OUTPUT, sequence and the assignment operator, selection with IF and CASE OF statements, iteration with count-controlled FOR loops, pre-condition WHILE loops and post-condition REPEAT loops, totalling and counting, the string routines LENGTH, SUBSTRING, UCASE and LCASE with both the zero-based and one-based position conventions, the arithmetic, relational and logical operators the syllabus limits candidates to, nested statements up to three levels, procedures and functions with up to three parameters and the difference between CALL and a function call inside an expression, local and global variables, the MOD, DIV, ROUND and RANDOM library routines in their current function-call notation, and how to write a maintainable program. Topic 8.2 covers declaring and using one-dimensional and two-dimensional arrays, the purpose of arrays, variable indexes, lower bounds of zero or one, and reading and writing array values using single and nested iteration. Topic 8.3 covers the purpose of storing data in a file and the OPENFILE, READFILE, WRITEFILE and CLOSEFILE operations for single data items and lines of text. Every worked example, trace and output in the chapter is verified, and the chapter includes fourteen interactive practice tools, seventeen diagrams, a misconception clinic, an exam-answer workshop and an integrated Paper 2 style scenario.Show moreShow less
Core Revision Module
Revision & Practice Book
Interactive revision notes with exam tips and worked examples for this chapter.
Practice & Resources
2 toolsChapter overview
A summary of this Computer Science chapter — open a section to read it. The full notes, worked examples and practice questions are in the study modules above.
What is Programming about?
A program is a stored sequence of instructions that manipulates data held in named storage. Topic 8 asks you to do four things with that idea. First, name and type your data correctly: a variable whose value may change, a constant whose value may not, each with one of the five data types INTEGER, REAL, CHAR, STRING, BOOLEAN. Second, control the order in which instructions run using only three structures — sequence, selection (IF, CASE) and iteration (FOR, WHILE, REPEAT). Third, break a long solution into procedures and functions so it stays readable and testable. Fourth, hold many related values in an array and hold them beyond the end of the run in a file. Everything else in this chapter is detail hanging off those four moves.
Paper 2, Algorithms, Programming and Logic, is a written paper of 1 hour 45 minutes worth 75 marks, which is 50% of the qualification. It consists of short-answer and structured questions plus one scenario-based question, set on Topics 7 to 10. All questions are compulsory and you answer on the question paper. Calculators are not allowed. The questions require you to have practical programming experience, but knowledge of programming-language syntax is not examined — in all cases the logic is more important than the syntax.
Cambridge sets out the exact form pseudocode takes in its examinations in Section 4 of the syllabus. Keywords are upper case (IF, REPEAT, PROCEDURE). Identifiers use Pascal case — mixed case with a capital starting each word, e.g. NumberOfPlayers — may contain only letters and digits, must start with a capital letter, must not use the underscore or accented characters, must never be a keyword, and are treated as case insensitive. Lines inside a statement are indented by four spaces, except the THEN and ELSE clauses of an IF and the cases of a CASE, which are indented by only two. Comments begin with // and run to the end of the line.
A variable is a named storage location whose value may change while the program runs; it is created with DECLARE <identifier> : <data type>. A constant is a named value that does not change while the program runs; it is created with CONSTANT <identifier> ← <value>, and only a literal may be used as the value — never a variable, another constant or an expression. Both must have a meaningful identifier. Every variable also has a data type that fixes what kind of value it can hold and what operations are legal on it.
Sequence means statements are executed one after another, in the order written, unless a control structure changes that order. INPUT <identifier> takes a value supplied by the user and stores it in the named variable. OUTPUT <value(s)> displays one or more values, separated by commas. Assignment is written <identifier> ← <value>: the expression on the right is evaluated first, and the single result is then stored in the variable on the left, replacing whatever was there. The identifier on the left must be a variable — it may be an element of a data structure such as an array — and the value must be of the same data type as the variable.
Selection means the program chooses which statements to execute according to whether a condition is TRUE or FALSE. Cambridge pseudocode has two selection structures. An IF statement tests a Boolean condition and may or may not have an ELSE clause; it is the right choice for ranges, comparisons and compound conditions. A CASE OF statement compares one identifier against a list of single discrete values, executes the statement of the first case that applies and then finishes; an OTHERWISE clause, if present, must be the last case.
Key ideas to remember
- If you remember nothing else: a trace table is the answer to almost every Topic 8 question that is not a definition. Columns for the variables, one row per change, a column for output. Fill it honestly and the mark scheme comes out of the table.
- Type test in six words: will I ever calculate with this? No → CHAR if one character, BOOLEAN if two states, otherwise STRING. Yes → REAL if a fraction is possible, otherwise INTEGER.
- Read the arrow as “becomes”. Evaluate the right using the values that exist right now, get one value, write it over the left. The equals sign never stores anything; it only ever asks a question.
- Range or compound → IF. A list of single values of one identifier → CASE. A matched case ends the statement; an ELSE is optional; OTHERWISE goes last.
- Known number of repeats → FOR. Might be none → WHILE. Must happen at least once → REPEAT. And remember the direction: WHILE keeps going while TRUE; REPEAT stops when TRUE.
- A total adds the value; a counter adds one. Both start at 0 before the loop. If the question says “how many that…”, the counter goes inside the IF; and any average built from a counter needs a guard against dividing by zero.
- Draw the ruler, then answer. LENGTH counts spaces. SUBSTRING takes a start and a count, not a start and an end. State your convention and never mix conventions inside one solution.
- DIV(A, B) * B + MOD(A, B) = A. Relational operators return Booleans; logical operators consume and return Booleans; and when an expression starts to need thinking about, it needed brackets.
What you need to be able to do
- Declare a variable and a constant of any of the five data types, and justify the type you chose. 8.1 A
- Distinguish declaration, initialisation, assignment and comparison, and use ← and = correctly. 8.1 A, 8.1 B
- Trace a sequence of assignments in a memory table and state the final value of every variable. 8.1 B
- Write and trace single-branch, two-branch and nested IF statements, and a CASE OF statement with OTHERWISE. 8.1 C
- Choose between IF and CASE, and justify the choice. 8.1 C
- Write and trace count-controlled, pre-condition and post-condition loops, and say exactly how many times each runs. 8.1 D
- Explain why a WHILE loop can run zero times and a REPEAT loop cannot. 8.1 D
- Build a running total and a counter in the same loop, and calculate an average without dividing by zero. 8.1 E
- Evaluate LENGTH, SUBSTRING, UCASE and LCASE by hand, stating the position convention you are using. 8.1 F
- Evaluate arithmetic, relational and logical expressions, including DIV, MOD, ^ and precedence. 8.1 G
- Use ROUND and RANDOM, and state precisely what RANDOM() returns. 8.1 G
- Match every opening keyword to its correct terminator in a listing nested up to three levels. 8.1 H
- Define and call a procedure with CALL, and a function inside an expression, each with up to three parameters. 8.1 I
- Explain the difference between a parameter and an argument, and between a procedure and a function. 8.1 I
- Decide whether a named variable is visible at a given point in a program, and say why. 8.1 J
- Improve a poorly written program's identifiers, comments and repeated code without changing what it does. 8.1 K
- Declare, fill, search and total a 1D array using iteration and a variable index. 8.2 A
- Traverse a 2D array with nested loops, by row and by column, without swapping the two. 8.2 B
- Sequence OPENFILE, READFILE/WRITEFILE and CLOSEFILE correctly, and say what FOR WRITE does to an existing file. 8.3 A
- Find, explain and correct a syntax defect and a logic defect in a given algorithm, and retest it. Debug and amend
Key terms in Programming
- Variable
- A named storage location, declared with an identifier and a data type, whose value may change while the program is running.
- Selection
- A control structure that chooses which statements to execute according to whether a condition evaluates to TRUE or FALSE; written in Cambridge pseudocode as an IF statement or a CASE OF statement.
- Local Variable
- A variable declared inside a procedure or function, available only within that routine; it cannot be read or changed from anywhere else in the program.
- Counting
- Recording how many times something has happened by adding one to a variable each time an event occurs; the counter is initialised to zero before the loop and incremented only when its condition is satisfied.
- String Handling
- Operations that examine or transform text: LENGTH returns the number of characters, UCASE and LCASE change case, and SUBSTRING returns a stated number of characters starting at a stated position.
- Procedure
- A named block of statements that performs a task and returns no value; it is started with the CALL statement and control returns to the line following the call.
- File
- A named collection of data held on secondary storage so that it persists after the program that created it has finished; it must be opened in READ or WRITE mode before use and closed when no longer needed.
- Assignment
- A statement that evaluates the expression on the right and stores the single resulting value in the variable on the left, replacing whatever was there.
- Maintainable Program
- A program written so that it can be read, understood and safely changed later, through meaningful identifiers, appropriate comments, decomposition into procedures and functions, consistent layout and no unnecessary repeated code.
- Iteration
- A control structure in which a block of statements is executed repeatedly; Cambridge pseudocode provides count-controlled FOR loops, pre-condition WHILE loops and post-condition REPEAT loops.
- Constant
- A named value fixed by a literal at the start of the program, which does not change while the program is running; it makes code clearer and easier to update.
- Array Index
- The number in square brackets that selects one element of an array; it may be a literal or a variable, must lie between the declared lower and upper bounds, and may start at zero or one depending on the declaration.
- Nested Statement
- A control structure written entirely inside the block of another control structure; the inner structure must open and close within the outer one, and candidates are not required to write more than three levels.
- Two-Dimensional Array
- An array declared with two pairs of bounds and pictured as a grid of rows and columns; each element is selected with one index for each dimension and the whole structure is traversed with nested iteration.
- Global Variable
- A variable declared outside all procedures and functions, available throughout the program including inside routines; convenient but easy to change by accident from anywhere.
- Totalling
- Accumulating a running total by repeatedly adding each data value to a variable that was initialised to zero before the loop; written as Total becomes Total plus Value.
- Function
- A named block of statements that performs a task and returns a single value of a declared data type to the point at which it was called; it is called inside an expression and never with CALL.
- Library Routine
- A ready-made routine provided with the language that a program can call without defining it, limited in this syllabus to MOD, DIV, ROUND and RANDOM.
- Array
- A fixed-length structure of elements of identical data type, held under one identifier and accessed by consecutive index numbers, so that one loop can process many related values.
Common mistakes to avoid
- M1. “A variable and a constant are basically the same — use whichever.” TruthA variable's value may change while the program runs; a constant's may not. They are also declared differently: DECLARE Counter : INTEGER against CONSTANT PassMark ← 50. TestIf the program ever assigns to it after the start, it must be a variable. If not, a constant is clearer and safer.
- M2. “CHAR and STRING are the same thing.” TruthA CHAR is a single character in single quotes: 'A'. A STRING is zero or more characters in double quotes: "A", "Ali", "". ConsequenceSUBSTRING returns a STRING, so compare its result with "A", not with 'A'.
- M3. “Assignment and equality use the same symbol.” TruthAssignment is ← and stores a value; equality is = and produces TRUE or FALSE. == does not exist in this notation at all. Read it asTotal ← 5 is “Total becomes 5”; IF Total = 5 is “is Total 5?”
- M4. “INPUT checks the data for me.” TruthINPUT stores whatever it is given in the named variable. It performs no validation of any kind. FixWrite the check yourself, usually a REPEAT ... UNTIL around the INPUT that only accepts values in range.
- M5. “Every IF needs an ELSE.” TruthIF statements may or may not have an ELSE clause. If nothing should happen when the condition is false, write no ELSE. WorseAn empty ELSE is not neutral — it suggests the writer expected something there and forgot it.
- M6. “CASE is the tidier choice, so use it for every selection.” TruthA case clause matches one single value of one identifier. It cannot express a range or a compound condition. RuleDiscrete values of one variable → CASE. Ranges, comparisons or AND/OR → IF. The specification itself says that if the cases are more complex, an IF should be considered.
- M7. “FOR Count ← 1 TO 5 runs four times — the limit is exclusive.” TruthBoth limits are inclusive. The variable is assigned every integer from value1 to value2, so this runs five times, with Count taking 1, 2, 3, 4 and 5. AlsoIf value1 = value2 it runs once; if value1 > value2 with the default step it runs not at all.
- M8. “A WHILE loop always runs at least once.” TruthThe condition is tested before the statements, and the statements will not be executed if the first test is FALSE. Zero executions is normal and often the point. Use itWhenever the question allows for “there may be no data at all”.
- M9. “A REPEAT loop can run zero times.” TruthIt cannot. The condition is tested after the statements, so the body always executes at least once. ConsequenceUsing REPEAT to read data that might not exist processes one item that was never there.
- M10. “Counting and totalling are the same operation.” TruthA total adds the data value: Total ← Total + Value. A counter adds one: Count ← Count + 1. They answer different questions. WatchA counter that answers “how many that…” must be inside the IF, not after ENDIF.
- M11. “DIV and MOD are written between the two numbers.” TruthThe current specification writes both as function calls: DIV(10, 3) returns 3 and MOD(10, 3) returns 1. Why you have seen otherwiseThe infix forms 10 DIV 3 and 10 MOD 3 are older; the operator names were updated during this syllabus cycle. Follow a question's own code if it uses the old style; write the current one otherwise.
- M12. “/ and DIV give the same answer.” Truth17 / 5 is 3.4, a REAL. DIV(17, 5) is 3, an INTEGER with the fractional part discarded — not rounded. NoteDiscarding is not rounding: DIV(19, 5) is 3, although 19 / 5 = 3.8 would round to 4.
- M13. “A comparison gives back a number, like 1 or 0.” TruthThe result of a relational operation is always of data type BOOLEAN — TRUE or FALSE. Use itThat is why Valid ← (Score >= 0) AND (Score <= 100) is legal: a relational expression is a Boolean value.
- M14. “AND and OR are more or less interchangeable.” TruthAND needs both operands TRUE; OR needs at least one. Swapping them changes the meaning completely. ExampleAge < 13 OR Age > 19 describes everyone who is not a teenager. Age < 13 AND Age > 19 describes nobody, because no number is both.
- M15. “The more deeply nested my solution, the more sophisticated it is.” TruthCandidates will not be required to write more than three levels of nested statements. Four levels signals an over-complicated design, not a clever one. FixMove the innermost block into a procedure or function, or replace a chain of nested IFs on one identifier with a flat CASE OF.
- M16. “A procedure gives a value back, just like a function.” TruthA procedure performs a task and returns no value. Only a function returns a value, and exactly one, of a declared data type. SymptomX ← PrintLine(5) — there is nothing for X to receive.
- M17. “You start a function with CALL, like a procedure.” TruthThe keyword CALL must not be used when calling a function. A function call is not a complete statement; it must appear as part of an expression. CorrectArea ← AreaOfRectangle(4.0, 2.5), or OUTPUT AreaOfRectangle(4.0, 2.5), or inside an IF condition.
- M18. “Parameter and argument are two words for the same thing.” TruthA parameter is the identifier in the routine's definition, with a data type. An argument is the actual value supplied in the call, which is substituted for the parameter when the routine runs. ExampleIn PROCEDURE PrintLine(Size : INTEGER) and CALL PrintLine(5), Size is the parameter and 5 is the argument.
- M19. “A local variable can be used anywhere in the program.” TruthA local variable is declared inside a procedure or function and is available only within that routine. Elsewhere the identifier refers to nothing. AlsoTwo routines cannot see each other's locals, and a local with the same name as a global is a different store.
- M20. “Making everything global is good practice — it saves passing things around.” TruthIt makes writing quicker and debugging slower. Any routine can change a global, so when one holds the wrong value every routine is a suspect, and no routine can be tested on its own. BetterPass values in as parameters and hand results back with a function's return value. Use a constant for a fixed value that several routines need.
- M21. “ROUND(RANDOM() * 5, 0) + 1 is a fair six-sided die.” TruthRANDOM() returns a random number between 0 and 1 inclusive, so the expression does give a whole number from 1 to 6 — the range is right. But rounding gives the two end values only half the span of each middle value, so 1 and 6 come up about half as often. In an examWrite the expression — it is the form the specification itself models — and describe it as producing a random whole number in the range. Do not claim it is fair.
- M22. “More comments always mean better code.” TruthThe syllabus asks for relevant and appropriate commenting. A comment that restates its line adds noise, and becomes wrong as soon as the line is edited and the comment is not. Commentthe purpose of a routine, an assumption, a non-obvious formula, a decision that needed thought. Not // add 1 to Count.
- M23. “Array indexes always start at 1.” TruthThe syllabus states that the first index can be zero or one. It is good practice to state the lower bound explicitly, because it defaults differently in different systems; generally a lower bound of 1 is used. DoRead the bound off the declaration and copy it into the loop, rather than assuming.
- M24. “The last index is the number of elements.” TruthTrue only when the lower bound is 1. ARRAY[0:7] has eight elements and a last index of 7. Number of elements= upper bound − lower bound + 1, because the bounds are inclusive.
- M25. “Rows and columns are interchangeable in a 2D array.” TruthThe first index and the second index are fixed by the declaration. On ARRAY[1:4, 1:3], writing Sales[Product, Week] asks for elements such as Sales[3,4], which is out of range. To change directionswap which loop is outermost, and leave the brackets alone.
- M26. “Data in a file disappears when the program finishes.” TruthExactly backwards. Variables and arrays live in main memory and are lost. A file is on secondary storage precisely so the data survives the end of the program. That is the purpose— and it is what an 8.3.1 question is asking you to explain.
- M27. “FOR WRITE adds to the end of the file.” TruthOpening a file FOR WRITE creates a new file, and any existing data in the file is lost — at the moment of opening, before any WRITEFILE runs. There is no APPEND modein this specification. To add to existing data: read it all in, then write it all back out with the addition.
- M28. “You can read a file without opening it first.” TruthA file must be opened, stating the mode, before reading from or writing to it — and a file should be opened in only one mode at a time. It should then be closed when it is no longer needed. Orderopen → read or write → process if required → close.
- M29. “Any pseudocode style is fine as long as a human can work out what I mean.” TruthSection 4 of the syllabus sets out exactly how pseudocode appears in the examinations, and several of the “style” slips change meaning: = for ←, a missing terminator, a missing loop update, a chained inequality. What is trueis that the syllabus states knowledge of programming language syntax is not examined, and that in all cases the logic is more important than the syntax. That is about the substance of the algorithm; it is not permission to write prose instead of one.
- M30. “Python is accepted throughout Paper 2, so I can answer in it.” TruthWhere a solution involves coding, candidates are required to write solutions in pseudocode, and solutions written in programming code will not be awarded marks. The one exception is the 15-mark scenario question, where pseudocode, Python, Visual Basic or Java are all accepted — and no other language is. Practical effectAnswering an ordinary Topic 8 question in Python scores zero for the code, however correct the logic is.
Examiner tips
- Read the closed lists as a promise in both directions. You will never be asked for a FOR EACH loop, a SWITCH, a string .split(), an APPEND file mode or a fourth parameter — none of those is in Topic 8. Equally, every single item that is listed is fair game, including the ones students skip: ^, <>, NOT, ROUND, RANDOM, 2D arrays and writing a line of text to a file.
- Version history you should know about, because old material contradicts it. Two things in the pseudocode specification changed during this syllabus cycle, and textbooks and worksheets printed before them are still in circulation. Integer division operators became function calls. Version 3 (January 2025) and version 4 (June 2025) both record that “the names of operators” were updated. The current specification writes DIV(<identifier1>, <identifier2>) and MOD(<identifier1>, <identifier2>), with the examples DIV(10, 3) returns 3 and MOD(10, 3) returns 1. The older infix forms 10 DIV 3 and 10 MOD 3 appear in a great deal of older material. This chapter uses the current function form throughout, and quotes the old form only to correct it. Parameter count was fixed at three. Version 4 records that “the number of parameters for a function and procedure has been updated”. Topic 8.1.6 now states that procedures and functions may have up to three parameters. Do not design an answer that needs four. Constants are declared with the arrow. The current specification gives the form CONSTANT <identifier> ← <value>, with the examples CONSTANT HourlyRate ← 6.50 and CONSTANT DefaultText ← "N/A". Some earlier material writes CONSTANT HourlyRate = 6.50. This chapter uses the arrow form, because it is what the current specification prints — so it is what you should train. Version 5 itself (December 2025) changed only a weblink on page 50. No Topic 8 content and no pseudocode convention changed between version 4 and version 5.
- The indentation rule that looks like a mistake but is not. The specification indents THEN and ELSE by only two spaces, because they are continuations of the IF statement rather than separate statements. The statements inside them are then indented by four. When IF statements are nested, the nesting continues that two-space pattern. Copy the shape from the listings in this chapter and you will never have to think about it again.
- Never change the loop-control variable inside a FOR loop. Writing Count ← Count + 3 inside a FOR Count loop makes the number of executions unpredictable to a reader and defeats the point of a count-controlled loop. If the step is not 1, use STEP. If the number of repetitions is not known in advance, you needed a WHILE or REPEAT in the first place.
- What to do in the exam. If the question states a convention — or its own pre-printed code uses one — follow it exactly. If the question is silent, use position 1 as the first character, which is what the specification calls the general case, and write one comment line saying so: // the first character is position 1. That sentence protects you if the marker expected the other convention, and costs nothing if they did not. This chapter uses position 1 throughout unless a heading says otherwise.
- DIV and MOD are written as function calls in the current specification. The forms are DIV(<identifier1>, <identifier2>), which “returns the quotient of identifier1 divided by identifier2 with the fractional part discarded”, and MOD(<identifier1>, <identifier2>), which “returns the remainder of identifier1 divided by identifier2”. Both identifiers are of data type integer. The specification's own examples are DIV(10, 3) returns 3 and MOD(10, 3) returns 1. The infix forms 10 DIV 3 and 10 MOD 3 come from an earlier version and from other languages. Use the function form. Follow a question's own pre-printed code if it uses the older style, but write the current one when the code is yours.
- The shortcut worth knowing. The five lines above can be written as one: Correct ← NOT (Answer < 0 OR Answer > 100), or more directly Correct ← (Answer >= 0) AND (Answer <= 100). Both are valid, because a relational expression is already a Boolean value and can be assigned straight to a BOOLEAN variable. Writing IF X = TRUE THEN Y ← TRUE ELSE Y ← FALSE ENDIF is never wrong, but it is four lines of ceremony around Y ← X.
- Three specification details students skip. (1) Procedures and functions are defined at the start of the code, before the main program that uses them. (2) The RETURN statement is normally the last statement in the function definition. (3) Up to three parameters — if your design needs a fourth, redesign it. And the rule that catches most people in a written answer: the keyword CALL must not be used when calling a function.
- How to write the answer. A “find the error” question asks for three separate things, and each one has to be written down: identify (quote the line or line number), explain (say what it does wrong, not just what it is), and correct (write the replacement line, not a description of it). “Line 11 is in the wrong place” does only the first. “Line 11 is outside the IF, so PassCount increases for every mark instead of only for passes; it should be moved inside the THEN block, before ENDIF” does all three.
Frequently asked questions
What is the difference between a variable and a constant?
A variable is a named storage location, declared with DECLARE and a data type, whose value may change while the program is running. A constant is a named value fixed with CONSTANT and a literal at the start of the program, and it must never change while the program runs — only a literal may be used as its value, never a variable, another constant or an expression. If a program ever assigns to it after the start, it must be a variable; if not, a constant is clearer and safer.
When should IF be used instead of CASE?
An IF statement tests a Boolean condition and is the right choice for ranges, comparisons and compound conditions using AND, OR or NOT. A CASE OF statement compares one identifier against a list of single discrete values, executes the statement of the first matching case, and then finishes, with an OTHERWISE clause, if present, always last. CASE cannot express a range or a compound condition, so discrete values of one variable point to CASE, while ranges or comparisons point to IF.
Why can a WHILE loop run zero times but a REPEAT loop cannot?
A WHILE loop tests its condition before the body runs, so if the first test is FALSE the statements inside never execute — zero executions is normal and is often exactly the point, for example when there may be no data at all. A REPEAT loop tests its condition after the body, so the body always executes at least once before the condition is even checked. Using REPEAT to read data that might not exist would wrongly process one item that was never there.
What is the difference between a procedure and a function?
A procedure is a named block of statements that performs a task and returns no value; it is started with the CALL statement, and control returns to the line after the call. A function performs a task and returns exactly one value of a declared data type to the point where it was called, so it is used inside an expression, such as an assignment or OUTPUT statement, and the keyword CALL must never be used with it. Both may take up to three parameters.
What is the difference between a parameter and an argument?
A parameter is the identifier named in a routine's definition, together with its data type, for example Size : INTEGER in PROCEDURE PrintLine(Size : INTEGER). An argument is the actual value supplied when the routine is called, for example the 5 in CALL PrintLine(5), which is substituted for the parameter when the routine runs. The two words describe the same position in a routine call from two different sides: the definition's side and the call's side.
Why are local variables generally preferred over global variables?
A local variable is declared inside a procedure or function and is available only within that routine, so it cannot be changed by accident from anywhere else in the program, which makes the routine easier to test on its own. A global variable is declared outside all routines and is available throughout the program, including inside every routine, so any routine can change it — when a global holds the wrong value, every routine that touches it becomes a suspect, and none can be tested in isolation.
What is the difference between DIV and the ordinary division operator /?
The / operator performs ordinary division and can return a REAL value with a fractional part, for example 17 / 5 gives 3.4. DIV(17, 5) performs integer division and discards the fractional part, giving 3, an INTEGER — it does not round, so DIV(19, 5) is 3, even though 19 / 5 is 3.8, which would round to 4. MOD returns the remainder from the same division, so MOD(17, 5) is 2.
Syllabus reference and sources
Written against: Cambridge O Level Computer Science (2210) 2026–2028 Syllabus (Subject Content, Topic 8: Programming).
Written by: Academiq Edu Instructor Panel
Source documents
All educational content, structured explanations, diagrams, worked examples, and pedagogical materials contained within this chapter revision note are the exclusive intellectual property of Academiq Edu. Unauthorized reproduction, distribution, resale, or extraction of this content without prior written permission is strictly prohibited under international copyright laws. Cambridge Assessment International Education (CAIE) is a registered trademark of Cambridge University Press & Assessment. This revision guide is independently authored by the Academiq Edu Instructor Panel for educational purposes and is not affiliated with or endorsed by Cambridge Assessment International Education.
Every chapter note, MCQ explanation, and structured mark scheme is rigorously vetted by Cambridge curriculum specialists.

