IGCSE Computer Science · Study guide

Programming

IGCSE Computer Science · Comprehensive Guide 8

Topic 8 · Programming

Write Cambridge pseudocode with correct data, control structures, routines, arrays, files, and maintainable design.

8 lesson sections · 8 worked applications · Paper 2 · Cambridge 0478 (2026–2028)

Prerequisite check

Algorithm construction and careful tracing of changing variable values.

Exam reasoning lens

Use Cambridge syntax exactly: PascalCase identifiers, ← assignment, named terminators, and the specified library routine forms.

Topic 8 · Section 1

Programming Concepts & Data Types

The defining description of variable is “is a named storage location whose value can change while a program runs.” Connect it with constant, whose role is “is a named value that is not changed while the program runs.”

Required vocabulary and boundaries

IdeaPrecise roleEvidence or example
variableis a named storage location whose value can change while a program runsScore increases after a correct answer
constantis a named value that is not changed while the program runsTaxRate used throughout a calculation
programming INTEGER typestores a whole number in a programNumberOfStudents = 28
programming REAL typestores a program number that can contain a fractional partTemperature = 21.5
CHAR and STRINGstore one character or a sequence of characters respectivelyGrade = 'A' and Name = "Amina"
programming BOOLEAN typestores one of the logical values TRUE or FALSE in a programFound = FALSE

Four-step exam routine

1

Identify the exact clue and name variable only when its defining role fits.

2

State the mechanism or boundary: is a named value that is not changed while the program runs.

3

Apply the idea to evidence such as “NumberOfStudents = 28.”

4

Reject the tempting error that stores only one text character.

Method and reasoning

Reason Before Naming

Good declarations make code easier to read and reduce mistakes when values are used later.

Start by underlining the clue in the scenario, then decide what job that clue is describing. This keeps the answer tied to the concept being assessed.

Answer pattern
A BOOLEAN is suitable for a flag such as IsMember because it stores only TRUE or FALSE.
Scenario clueWhat it proves
value changesvariable
value fixedconstant
single characterCHAR
many charactersSTRING
Worked application

When The Scenario Is Less Obvious

The question may include a boundary case or a tempting wrong answer. Use the exact role in the scenario as evidence.

  • identifier: a name used for a variable, constant, array, or subroutine
  • variable: a named value that can change while a program runs
  • constant: a named value that should not change while a program runs
  • data type: the kind of data a value stores

A strong answer uses the exact stored value and whether it changes as evidence.

TermUse in this lesson
identifiera name used for a variable, constant, array, or subroutine
variablea named value that can change while a program runs
constanta named value that should not change while a program runs
data typethe kind of data a value stores
Boundary and misconception

A Common Mix-Up

A common mistake is choosing a data type from the example's topic instead of the actual value.

Fix: Ask whether the value changes, then match the type to the exact value being stored.

MistakeCorrection
A common mistake is choosing a data type from the example's topic instead of the actual value.Ask whether the value changes, then match the type to the exact value being stored.
Topic 8 · Section 2

Basic Syntax, IO & Operators

The defining description of sequence is “executes statements in their written order unless control flow changes it.” Connect it with INPUT statement, whose role is “receives a value and stores it in a variable.”

Required vocabulary and boundaries

IdeaPrecise roleEvidence or example
sequenceexecutes statements in their written order unless control flow changes itINPUT Price before calculating Total
INPUT statementreceives a value and stores it in a variableINPUT Age
OUTPUT statementdisplays a value, expression, or messageOUTPUT Total
assignmentevaluates an expression and stores the result using the left-arrow operatorTotal ← Price * Quantity
arithmetic and relational operatorsperform calculations or compare values using the defined symbols+, −, /, *, ^ and <, <=, =, <>
MOD, DIV, ROUND, and RANDOMprovide remainder, integer quotient, rounding, and random-value operationsMOD(17, 5), DIV(17, 5), ROUND(Value, 2), and RANDOM()

Four-step exam routine

1

Identify the exact clue and name sequence only when its defining role fits.

2

State the mechanism or boundary: receives a value and stores it in a variable.

3

Apply the idea to evidence such as “OUTPUT Total.”

4

Reject the tempting error that uses an equals sign only to compare two values.

Method and reasoning

Reason Before Naming

Understanding the result of each line helps predict what the program will output.

Start by underlining the clue in the scenario, then decide what job that clue is describing. This keeps the answer tied to the concept being assessed.

Answer pattern
17 MOD 5 is 2 because 17 divided by 5 leaves a remainder of 2.
Scenario clueWhat it proves
read typed valueINPUT
display answerOUTPUT
quotientDIV
remainderMOD
combine conditionsAND/OR/NOT
Worked application

When The Scenario Is Less Obvious

The question may include a boundary case or a tempting wrong answer. Use the exact role in the scenario as evidence.

  • INPUT: statement that reads a value into a variable
  • OUTPUT: statement that displays or sends a value
  • sequence: statements running in the order written
  • operator: symbol or word used to calculate or compare values

A strong answer names the statement or operator and explains the value it produces.

TermUse in this lesson
INPUTstatement that reads a value into a variable
OUTPUTstatement that displays or sends a value
sequencestatements running in the order written
operatorsymbol or word used to calculate or compare values
Boundary and misconception

A Common Mix-Up

A common mistake is swapping INPUT and OUTPUT.

Fix: Say whether the statement reads, displays, calculates, compares, or combines conditions.

MistakeCorrection
A common mistake is swapping INPUT and OUTPUT.Say whether the statement reads, displays, calculates, compares, or combines conditions.
Topic 8 · Section 3

Selection Constructs

The defining description of selection is “chooses which statements execute according to a condition or value.” Connect it with IF branch, whose role is “executes its statements when the Boolean condition is TRUE.”

Required vocabulary and boundaries

IdeaPrecise roleEvidence or example
selectionchooses which statements execute according to a condition or valuedisplaying Pass only when Mark >= 50
IF branchexecutes its statements when the Boolean condition is TRUEIF Age >= 18 THEN
ELSE branchprovides an alternative when the IF condition is FALSEoutputting Not eligible
nested selectionplaces a selection statement inside another selection branchchecking membership after checking age
CASE statementselects one branch according to the value of one expressionCASE OF MenuChoice
logical selection conditioncombines Boolean tests with AND, OR, or NOT when neededAge >= 18 AND HasID = TRUE

Four-step exam routine

1

Identify the exact clue and name selection only when its defining role fits.

2

State the mechanism or boundary: executes its statements when the Boolean condition is TRUE.

3

Apply the idea to evidence such as “outputting Not eligible.”

4

Reject the tempting error that is forbidden at every nesting level.

Method and reasoning

Reason Before Naming

Selection makes a program respond differently to different values or conditions.

Start by underlining the clue in the scenario, then decide what job that clue is describing. This keeps the answer tied to the concept being assessed.

Answer pattern
CASE is suitable for a menu because the same variable is compared with several exact choices.
Scenario clueWhat it proves
Score >= 50IF
MenuChoice = 1, 2, 3CASE
invalid menu valueOTHERWISE
false branchELSE
Worked application

When The Scenario Is Less Obvious

The question may include a boundary case or a tempting wrong answer. Use the exact role in the scenario as evidence.

  • condition: test that is TRUE or FALSE
  • IF: selection structure for a condition
  • ELSE: branch used when the IF condition is false
  • CASE: selection structure for one value with several possible matches

A strong answer says which branch runs and why.

TermUse in this lesson
conditiontest that is TRUE or FALSE
IFselection structure for a condition
ELSEbranch used when the IF condition is false
CASEselection structure for one value with several possible matches
Boundary and misconception

A Common Mix-Up

A common mistake is saying IF is a loop.

Fix: Trace the TRUE or FALSE result and use indentation or ENDIF positions to keep branches clear.

MistakeCorrection
A common mistake is saying IF is a loop.Trace the TRUE or FALSE result and use indentation or ENDIF positions to keep branches clear.
Topic 8 · Section 4

Iteration Constructs (Loops)

The defining description of count-controlled loop is “repeats a known number of times using a control variable.” Connect it with FOR loop update, whose role is “changes the control variable automatically through the stated range.”

Required vocabulary and boundaries

IdeaPrecise roleEvidence or example
count-controlled looprepeats a known number of times using a control variableFOR Index ← 1 TO 10
FOR loop updatechanges the control variable automatically through the stated rangeIndex takes each value from 1 to 10
pre-condition looptests its condition before each repetition and may execute zero timesWHILE Password <> CorrectPassword DO
post-condition loopexecutes its body before testing the condition and therefore runs at least onceREPEAT ... INPUT Value ... UNTIL Valid = TRUE
loop terminationrequires the loop state to move toward a condition that eventually stops repetitionCount ← Count + 1 inside a WHILE loop
nested iterationplaces one loop inside another, with no more than three levels of nested statements requiredrow and column loops for a table

Four-step exam routine

1

Identify the exact clue and name count-controlled loop only when its defining role fits.

2

State the mechanism or boundary: changes the control variable automatically through the stated range.

3

Apply the idea to evidence such as “WHILE Password <> CorrectPassword DO.”

4

Reject the tempting error that tests before the first statement.

Method and reasoning

Reason Before Naming

Loop choice affects whether code runs the correct number of times.

Start by underlining the clue in the scenario, then decide what job that clue is describing. This keeps the answer tied to the concept being assessed.

Answer pattern
A WHILE loop may run zero times because the condition is checked before the loop body.
Scenario clueWhat it proves
fixed countFOR
unknown count, pre-checkWHILE
unknown count, post-checkREPEAT UNTIL
Worked application

When The Scenario Is Less Obvious

The question may include a boundary case or a tempting wrong answer. Use the exact role in the scenario as evidence.

  • FOR loop: count-controlled loop with a known number of repeats
  • WHILE loop: pre-condition loop that checks before each repeat
  • REPEAT UNTIL loop: post-condition loop that checks after the body runs
  • condition-controlled loop: loop controlled by a TRUE or FALSE test

A strong answer states when the condition is checked and what makes the loop stop.

TermUse in this lesson
FOR loopcount-controlled loop with a known number of repeats
WHILE looppre-condition loop that checks before each repeat
REPEAT UNTIL looppost-condition loop that checks after the body runs
condition-controlled looploop controlled by a TRUE or FALSE test
Boundary and misconception

A Common Mix-Up

A common mistake is choosing WHILE for every repeated task.

Fix: Ask whether the count is known, whether the condition is checked before, and whether the body must run once.

MistakeCorrection
A common mistake is choosing WHILE for every repeated task.Ask whether the count is known, whether the condition is checked before, and whether the body must run once.
Topic 8 · Section 5

String Handling & Library Routines

The defining description of LENGTH is “returns the number of characters in a string.” Connect it with SUBSTRING, whose role is “returns part of a string from a stated starting position and length.”

Required vocabulary and boundaries

IdeaPrecise roleEvidence or example
LENGTHreturns the number of characters in a stringLENGTH("CODE") returns 4
SUBSTRINGreturns part of a string from a stated starting position and lengthextracting three characters from a product code
UCASEreturns a string converted to uppercaseUCASE("Seoul") gives "SEOUL"
LCASEreturns a string converted to lowercaseLCASE("YES") gives "yes"
string index origincan begin at position zero or one according to the convention stated in the questionusing the supplied first-character position
string-routine compositioncan combine returned values in a larger expressionUCASE(SUBSTRING(Code, 1, 2))

Four-step exam routine

1

Identify the exact clue and name LENGTH only when its defining role fits.

2

State the mechanism or boundary: returns part of a string from a stated starting position and length.

3

Apply the idea to evidence such as “UCASE("Seoul") gives "SEOUL".”

4

Reject the tempting error that selects a random string.

Method and reasoning

Reason Before Naming

Text processing often fails because the program treats characters and numbers as if they were the same.

Start by underlining the clue in the scenario, then decide what job that clue is describing. This keeps the answer tied to the concept being assessed.

Answer pattern
SUBSTRING("Science", 1, 3) returns "Sci" because it starts at position 1 and takes 3 characters.
Scenario clueWhat it proves
password lengthLENGTH
first three lettersSUBSTRING
case-insensitive compareUCASE/LCASE
calculate with digitCHARtoNUM
Worked application

When The Scenario Is Less Obvious

The question may include a boundary case or a tempting wrong answer. Use the exact role in the scenario as evidence.

  • string: sequence of characters
  • LENGTH: function that returns the number of characters
  • SUBSTRING: function that extracts part of a string
  • UCASE/LCASE: functions that change letter case

A strong answer shows the positions or characters being counted.

TermUse in this lesson
stringsequence of characters
LENGTHfunction that returns the number of characters
SUBSTRINGfunction that extracts part of a string
UCASE/LCASEfunctions that change letter case
Boundary and misconception

A Common Mix-Up

A common mistake is forgetting that spaces are characters.

Fix: Write positions under the string, count spaces, and check whether the value is text or numeric.

MistakeCorrection
A common mistake is forgetting that spaces are characters.Write positions under the string, count spaces, and check whether the value is text or numeric.
Topic 8 · Section 6

One- & Two-Dimensional Arrays

The defining description of one-dimensional array is “stores an indexed list of values of the same data type.” Connect it with two-dimensional array, whose role is “stores values addressed by two indexes such as row and column.”

Required vocabulary and boundaries

IdeaPrecise roleEvidence or example
one-dimensional arraystores an indexed list of values of the same data typeMarks[1:30]
two-dimensional arraystores values addressed by two indexes such as row and columnSeats[1:20, 1:6]
array declarationstates the identifier, index bounds, dimensions, and element data typeDECLARE Names : ARRAY[1:30] OF STRING
array indexselects a particular element and can be a variableMarks[StudentIndex]
array write and readassigns a value to an indexed element and later retrieves it using the same addressMarks[3] ← 72 then OUTPUT Marks[3]
array iterationuses a loop to process a sequence of indexes and nested loops for two dimensionsvisit every row and column

Four-step exam routine

1

Identify the exact clue and name one-dimensional array only when its defining role fits.

2

State the mechanism or boundary: stores values addressed by two indexes such as row and column.

3

Apply the idea to evidence such as “DECLARE Names : ARRAY[1:30] OF STRING.”

4

Reject the tempting error that must be a fixed text string.

Method and reasoning

Reason Before Naming

Arrays reduce repeated variable names and make loops over related data easier.

Start by underlining the clue in the scenario, then decide what job that clue is describing. This keeps the answer tied to the concept being assessed.

Answer pattern
Seats[2,5] means row 2, column 5 in a 2D array.
Scenario clueWhat it proves
five scores1D array
seat grid2D array
visit all list itemssingle loop
visit all grid cellsnested loops
Worked application

When The Scenario Is Less Obvious

The question may include a boundary case or a tempting wrong answer. Use the exact role in the scenario as evidence.

  • array: data structure containing multiple values of the same type
  • index: position used to access an array element
  • 1D array: list accessed with one index
  • 2D array: table or grid accessed with row and column indexes

A strong answer states the array name, dimension, and exact element being accessed.

TermUse in this lesson
arraydata structure containing multiple values of the same type
indexposition used to access an array element
1D arraylist accessed with one index
2D arraytable or grid accessed with row and column indexes
Boundary and misconception

A Common Mix-Up

A common mistake is confusing the array size with an element value.

Fix: Name the array, count the indexes, and state what each index represents.

MistakeCorrection
A common mistake is confusing the array size with an element value.Name the array, count the indexes, and state what each index represents.
Topic 8 · Section 7

Subroutines & File Handling

The defining description of procedure is “a named subroutine that performs actions without returning a value.” Connect it with function, whose role is “a named subroutine that returns one value and is called inside an expression.”

Required vocabulary and boundaries

IdeaPrecise roleEvidence or example
procedurea named subroutine that performs actions without returning a valuePROCEDURE DisplayMenu OUTPUT "Menu" ENDPROCEDURE
functiona named subroutine that returns one value and is called inside an expressionFUNCTION Total(Price : REAL, Quantity : INTEGER) RETURNS REAL
parameterpasses a value into a procedure or function; a subroutine may have up to three parameters and each header parameter includes its data typePrice : REAL
local variablea variable available only inside the subroutine where it is declaredSubtotal declared inside a function
global variablea variable available across the programa shared GameState value
file operation sequenceOPENFILE in READ or WRITE mode before READFILE or WRITEFILE, followed by CLOSEFILEreading or writing one line of text

Four-step exam routine

1

Identify the exact clue and name procedure only when its defining role fits.

2

State the mechanism or boundary: a named subroutine that returns one value and is called inside an expression.

3

Apply the idea to evidence such as “Price : REAL.”

4

Reject the tempting error that is available everywhere in the program.

Method and reasoning

Reason Before Naming

Subroutines make programs modular, and correct file handling protects stored data.

Start by underlining the clue in the scenario, then decide what job that clue is describing. This keeps the answer tied to the concept being assessed.

Answer pattern
A parameter is a value supplied to a subroutine so the same code can work with different inputs.
Scenario clueWhat it proves
reusable display taskprocedure
computed value neededfunction
different input valuesparameters
read saved dataOPENFILE READ
Worked application

When The Scenario Is Less Obvious

The question may include a boundary case or a tempting wrong answer. Use the exact role in the scenario as evidence.

  • procedure: subroutine that performs actions without returning a value
  • function: subroutine that returns a value
  • parameter: value passed into a subroutine
  • file handling: opening, reading, writing, appending, and closing files

A strong answer names the construct and describes the data moving in or out.

TermUse in this lesson
proceduresubroutine that performs actions without returning a value
functionsubroutine that returns a value
parametervalue passed into a subroutine
file handlingopening, reading, writing, appending, and closing files
Boundary and misconception

A Common Mix-Up

A common mistake is calling every subroutine a function.

Fix: Look for RETURN to identify functions, and use the file sequence open, read/write, close.

MistakeCorrection
A common mistake is calling every subroutine a function.Look for RETURN to identify functions, and use the file sequence open, read/write, close.
Topic 8 · Section 8

Maintainable Programs

The defining description of meaningful identifier is “describes the purpose of a variable, constant, array, procedure, or function.” Connect it with relevant comment, whose role is “explains purpose or a non-obvious decision.”

Required vocabulary and boundaries

IdeaPrecise roleEvidence or example
meaningful identifierdescribes the purpose of a variable, constant, array, procedure, or functionTotalScore instead of X
relevant commentexplains purpose or a non-obvious decision// convert seconds to whole minutes
procedure used for maintainabilityplaces a reusable action in one named subroutine so it can be changed onceone DisplayMenu procedure called from several places
function used for maintainabilityplaces a reusable calculation in one returning subroutine so its logic has one point of changeone CalculateAverage function used by several reports
single point of changeallows repeated logic to be corrected in one subroutineone validation procedure used by several inputs
readable structureuses consistent indentation and well-scoped modulesnested IF blocks aligned clearly

Four-step exam routine

1

Identify the exact clue and name meaningful identifier only when its defining role fits.

2

State the mechanism or boundary: explains purpose or a non-obvious decision.

3

Apply the idea to evidence such as “one DisplayMenu procedure called from several places.”

4

Reject the tempting error that is copied wherever its result is needed.

Method and reasoning

Reason Before Naming

These terms are usually assessed through short scenarios, so the mark often comes from matching the clue rather than recalling a definition alone.

Start by underlining the clue in the scenario, then decide what job that clue is describing. This keeps the answer tied to the concept being assessed.

Answer pattern
maintainability is the best match when the scenario clue is 'future editing'.
Scenario clueWhat it proves
future editingmaintainability
explain purposecomment
avoid repeated menuprocedure
show IF bodyindentation
Worked application

When The Scenario Is Less Obvious

The question may include a boundary case or a tempting wrong answer. Use the exact role in the scenario as evidence.

  • maintainability: how easy code is to understand and change
  • meaningful identifier: name that clearly describes stored data or a subroutine
  • comment: note explaining code for human readers
  • indentation: spacing that shows program structure

A strong answer names the idea, quotes or paraphrases the clue, and explains the link in one sentence.

TermUse in this lesson
maintainabilityhow easy code is to understand and change
meaningful identifiername that clearly describes stored data or a subroutine
commentnote explaining code for human readers
indentationspacing that shows program structure
Boundary and misconception

A Common Mix-Up

A common mistake is stopping at a broad Maintainable Programs word instead of proving the answer from the clue.

Fix: Underline the clue first, then choose the term that explains that exact clue.

MistakeCorrection
A common mistake is stopping at a broad Maintainable Programs word instead of proving the answer from the clue.Underline the clue first, then choose the term that explains that exact clue.
Paper 2 response lab

Turn knowledge into marks

A high-quality response does more than recall a term. It selects the command word, states the exact role, follows the mechanism in order, and connects the effect to the scenario.

Define precisely

For variable, begin with the defining role: is a named storage location whose value can change while a program runs. Do not replace the definition with an example.

Describe a process

Use an ordered chain. Name what enters, what changes or is checked, and what result follows. A useful anchor here is “NumberOfStudents = 28.”

Apply or justify

Quote the scenario need, select single point of change, then link its role — allows repeated logic to be corrected in one subroutine — to the required outcome.

Repair a misconception

Do not accept the claim that removes all whitespace. Replace it with the exact boundary: uses consistent indentation and well-scoped modules.

Mark-by-mark response ladder

  1. Name: use the exact syllabus term.
  2. Role: define what that term does or represents.
  3. Mechanism: describe the relevant steps in their logical order.
  4. Context: explain why that mechanism matters in the stated scenario.
  5. Boundary: avoid claiming more than the method guarantees.

Last-pass checklist

Programming Concepts & Data Typesvariable — is a named storage location whose value can change while a program runs.
Basic Syntax, IO & Operatorssequence — executes statements in their written order unless control flow changes it.
Selection Constructsselection — chooses which statements execute according to a condition or value.
Iteration Constructs (Loops)count-controlled loop — repeats a known number of times using a control variable.
String Handling & Library RoutinesLENGTH — returns the number of characters in a string.
One- & Two-Dimensional Arraysone-dimensional array — stores an indexed list of values of the same data type.
Subroutines & File Handlingprocedure — a named subroutine that performs actions without returning a value.
Maintainable Programsmeaningful identifier — describes the purpose of a variable, constant, array, procedure, or function.

Mapped to Cambridge IGCSE Computer Science 0478 · 2026–2028 syllabus, version 5