Revision Notes
IGCSE Computer Science: Programming — Revision Notes
Revision notes on data types, selection, loops, string handling, operators, subroutines, library routines, arrays and files for Cambridge IGCSE CS 0478.
- Subject
- Computer Science
- Level
- IGCSE
- Topic
- Programming
- Author
- Marlbridge Academic Team
- Updated
- Reviewed by
- Harris Khan (what this means)
Aligned to Cambridge IGCSE Computer Science (0478), 2026-2028. Official specification .
Syllabus page (what it covers and how it is assessed): Cambridge IGCSE Computer Science.
Syllabus points this page covers
0478
- 8 Programming (whole topic)
Found an error? Report a correction.
Need help with this topic? Request a free trial class for IGCSE Computer Science (0478).
Topic 8 Programming covers the building blocks of every program: variables and constants, data types, sequence, selection and iteration, string handling, operators, subroutines, library routines, arrays and file handling. In Cambridge IGCSE Computer Science (0478) it is examined on Paper 2, where you write and read Cambridge-style pseudocode; the syllabus says the logic matters more than the syntax of any one language.
Condensed for the final weeks. For the full explanations, use the Programming study guide; then practise with the Programming practice questions.
Syllabus coverage
Learning outcomes from the Cambridge IGCSE Computer Science 0478 syllabus for 2026, 2027 and 2028:
| Ref | Learning outcome (summarised) |
|---|---|
| 8.1.1 | Declare and use variables and constants |
| 8.1.2 | Basic data types: integer, real, char, string, Boolean |
| 8.1.3 | Input and output |
| 8.1.4 | Sequence; selection (IF, CASE); iteration (count-controlled, pre-condition, post-condition); totalling and counting; string handling; arithmetic, relational and logical operators |
| 8.1.5 | Nested statements (up to three levels) |
| 8.1.6 | Procedures, functions, parameters; local and global variables |
| 8.1.7 | Library routines: MOD, DIV, ROUND, RANDOM |
| 8.1.8 | Creating a maintainable program |
| 8.2 | 1D and 2D arrays, using variables as indexes, reading and writing with iteration |
| 8.3 | File handling: purpose, open, close, read and write |
8.1 Variables, constants and data types
DECLARE Score : INTEGER
CONSTANT Pi ← 3.142
A variable can change while the program runs; a constant cannot. Constants make code easier to read and update — change the value once and every use changes.
| Data type | Holds | Example |
|---|---|---|
| INTEGER | Whole numbers | 42 |
| REAL | Numbers with a fractional part | 3.75 |
| CHAR | A single character | ‘Y’ |
| STRING | A sequence of characters | “Lahore” |
| BOOLEAN | TRUE or FALSE | TRUE |
Selection and iteration
| Construct | Pseudocode | Use when |
|---|---|---|
| IF | IF ... THEN ... ELSE ... ENDIF |
One or two conditions |
| CASE | CASE OF Choice ... OTHERWISE ... ENDCASE |
One variable compared with several values |
| Count-controlled | FOR Count ← 1 TO 10 ... NEXT Count |
Number of repeats is known |
| Pre-condition | WHILE Condition DO ... ENDWHILE |
Condition tested first; may run zero times |
| Post-condition | REPEAT ... UNTIL Condition |
Condition tested last; always runs at least once |
CASE OF Grade
'A' : OUTPUT "Excellent"
'B' : OUTPUT "Good"
OTHERWISE OUTPUT "Keep practising"
ENDCASE
Operators
| Type | Operators |
|---|---|
| Arithmetic | + - / * ^ (power), MOD, DIV |
| Relational | = < <= > >= <> (not equal) |
| Logical | AND OR NOT |
String handling
| Function | Returns | Example |
|---|---|---|
LENGTH(S) |
Number of characters | LENGTH("Happy Days") → 10 |
SUBSTRING(S, Start, Len) |
Part of the string | SUBSTRING("Happy Days", 1, 5) → “Happy” |
UCASE(S) |
Upper case | UCASE("Happy") → “HAPPY” |
LCASE(S) |
Lower case | LCASE('W') → ‘w’ |
The syllabus allows the first character to be position 0 or 1; in Cambridge pseudocode it is generally 1. State which you are using if it matters.
Library routines
| Routine | Returns | Example |
|---|---|---|
DIV(A, B) |
Whole-number quotient | DIV(10, 3) → 3 |
MOD(A, B) |
Remainder | MOD(10, 3) → 1 |
ROUND(X, Places) |
X rounded to that many decimal places | ROUND(7.468, 1) → 7.5 |
RANDOM() |
Random number from 0 to 1 inclusive | ROUND(RANDOM() * 6, 0) → whole number 0 to 6 |
MOD is useful for testing even numbers (MOD(N, 2) = 0); DIV for converting units, such as minutes into whole hours.
Procedures, functions and scope
- A procedure is a named block of code that performs a task; it is run with
CALL. - A function is a named block of code that returns a value, so it is used in an expression.
- A parameter is a value passed into the subroutine (up to three in the exam).
- A local variable exists only inside the subroutine where it is declared; a global variable can be used anywhere in the program.
FUNCTION Area(Length : REAL, Width : REAL) RETURNS REAL
RETURN Length * Width
ENDFUNCTION
PROCEDURE Stars(Number : INTEGER)
FOR Count ← 1 TO Number
OUTPUT "*"
NEXT Count
ENDPROCEDURE
CALL Stars(5)
Floor ← Area(4.5, 3.0)
Maintainable programs
Use meaningful identifiers (for variables, constants, arrays, procedures and functions), comments (// in pseudocode) that explain what sections do, and procedures and functions so code is reused rather than repeated.
8.2 Arrays
DECLARE Temps : ARRAY[1:7] OF REAL
DECLARE Seats : ARRAY[1:10, 1:20] OF CHAR
A 2D array is read with nested loops — the outer loop for rows, the inner loop for columns:
FOR Row ← 1 TO 10
FOR Col ← 1 TO 20
Seats[Row, Col] ← 'E'
NEXT Col
NEXT Row
8.3 File handling
Data stored in a file is kept after the program closes, so it can be used next time or by another program.
OPENFILE "Scores.txt" FOR WRITE
WRITEFILE "Scores.txt", PlayerName
CLOSEFILE "Scores.txt"
OPENFILE "Scores.txt" FOR READ
READFILE "Scores.txt", LineOfText
CLOSEFILE "Scores.txt"
Opening a file FOR WRITE creates a new file and any existing data in it is lost.
Worked example: a procedure with a parameter and library routines
Write a procedure that takes a whole number of seconds and outputs it in minutes and seconds, such as 135 → 2 min 15 s.
PROCEDURE ShowTime(Total : INTEGER)
DECLARE Mins : INTEGER
DECLARE Secs : INTEGER
Mins ← DIV(Total, 60)
Secs ← MOD(Total, 60)
OUTPUT Mins, " min ", Secs, " s"
ENDPROCEDURE
CALL ShowTime(135)
DIV(135, 60) = 2 and MOD(135, 60) = 15, so the output is “2 min 15 s”. Mins and Secs are local variables: they exist only while the procedure runs. If the program needed the minutes value afterwards, a function returning Mins would be the better choice.
Common mistakes / exam traps
- Using a FOR loop when the number of repeats is not known in advance.
- Confusing DIV (quotient) with MOD (remainder).
- Writing
=for assignment; Cambridge pseudocode uses←for assignment and=for comparison. - Choosing INTEGER for money or measurements that need decimals; choose REAL.
- Storing a phone number as INTEGER — it should be STRING (leading zeros, no arithmetic).
- Forgetting
RETURNin a function, or calling a function withCALLas if it were a procedure. - Opening a file FOR WRITE when you meant to keep its existing contents.
- Forgetting to close a file.
Frequently asked questions
What is the difference between a procedure and a function? Both are named subroutines. A function returns a single value to the point where it was called, so it is used in an expression; a procedure does not return a value and is run with CALL.
When should I use a WHILE loop rather than a REPEAT loop? Use WHILE when the loop might not need to run at all, because its condition is tested first. REPEAT always runs at least once, which suits input validation.
Can I write Paper 2 answers in Python? Only in the 15-mark scenario question, where 0478 accepts pseudocode, Python, Visual Basic or Java. Elsewhere on Paper 2, use pseudocode.
Self-test
- State the most suitable data type for a person’s initial.
- Give the value of
MOD(29, 4)andDIV(29, 4). - Which loop always runs at least once?
- State one reason for using a global variable and one problem it can cause.
- What does
SUBSTRING("Computer", 4, 3)return?
Answers: 1. CHAR. 2. 1 and 7. 3. The post-condition (REPEAT … UNTIL) loop. 4. It can be used by every subroutine without passing it as a parameter; any part of the program can change it, which makes errors harder to trace. 5. “put”.
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
-
Practice questions
IGCSE Computer Science: Programming — Practice Questions (Cambridge 0478)
Original pseudocode questions with answers on loops, CASE, string functions, MOD and DIV, 2D arrays, functions, scope and file handling for IGCSE 0478.
Computer Science · Cambridge · IGCSE
Try questions -
Practice questions
IGCSE Computer Science: Software — Practice Questions (Cambridge 0478)
Original Paper 1 style questions with mark-scheme answers on software types, firmware, interrupts, assembly language and translators for Cambridge IGCSE 0478.
Computer Science · Cambridge · IGCSE
Try questions -
Revision notes
IGCSE Computer Science: Software — Revision Notes
Quick-recall notes on system and application software, OS functions, interrupts, firmware, translators and IDEs for Cambridge IGCSE Computer Science 0478.
Computer Science · Cambridge · IGCSE
Revise topic
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 IGCSE?
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