IGCSE Computer Science Paper 2

These are free worksheets for Paper 2 (Algorithms, Programming and Logic) of the Cambridge IGCSE Computer Science syllabus, 0478: topics 7 to 10, covering algorithm design and problem-solving, programming, databases and Boolean logic.

This page lists the 499 modules written for Paper 2, one section per syllabus topic: the program development life cycle, decomposition, abstraction, structure diagrams and flowcharts; Cambridge pseudocode conventions, DECLARE, CONSTANT, assignment with ←, INPUT and OUTPUT, arithmetic, DIV and MOD, relational and logical operators; IF, CASE, FOR, WHILE and REPEAT; the standard methods of solution: totalling, counting, maximum, minimum and average, linear search and bubble sort; validation, verification, test data and trace tables; data types, variables and constants, string handling, procedures, functions, parameters, local and global variables and library routines; one- and two-dimensional arrays; reading and writing files; single-table databases and SQL SELECT, WHERE, SUM and COUNT; and logic gates, truth tables, logic expressions and logic circuits. Topics that appear in more than one part of the syllabus, such as IF … THEN … ENDIF, have a worksheet in each part, labelled with the syllabus section. Each module includes real practice questions, worked examples and a full answer key.

Each topic has its own journey below, and the larger topics are also split into smaller journeys, so teachers can assign a whole topic or one part of it, with progress tracking, class sprints and badges.

Add this whole curriculum to your class, or just the modules your unit needs — Cloodit tracks who's stuck automatically.

7a Program Development Life Cycle (80 modules)

1
The program development life cycle The four ordered stages that take a program from problem to working code: analysis, design, coding and testing. Planning before coding saves time.
2
The analysis stage The first stage of the PDLC: work out exactly what problem must be solved and what the program must do, using abstraction and decomposition, before any design or code.
3
Identifying the problem A clear one or two sentence description of what needs to be solved and what the program must achieve, written so the user and the goal are obvious.
4
Abstraction (7a) Keeping only the details needed to solve a problem and leaving out the details that do not matter, e.g. a map shows roads but not every tree.
6
Requirements of a program A statement of something the program must do or provide so that the problem is solved. It is specific, comes from the problem and the user, and is used later to test the program.
7
Inputs, processes, outputs and storage The four parts of a program's requirements: the data it takes in, the work it does on that data, the results it shows, and the data it keeps for later.
8
The design stage The second PDLC stage: plan the solution in detail using decomposition, structure diagrams, flowcharts and pseudocode, before any program code is written.
10
Cambridge flowchart symbols (7a) Six standard flowchart shapes: terminator (Start/Stop), process, input/output, decision (two exits), subroutine call, and flow lines with arrows showing direction.
15
The coding stage The third PDLC stage, where the design (pseudocode or flowchart) is turned into program code in a programming language, written step by step and checked against the requirements.
16
Iterative testing while coding Testing each small part of the code as it is written, fixing any errors, then retesting before moving on. This finds errors early and repeats until that part works.
17
The testing stage The final PDLC stage: run the finished program with test data, compare results with expected results, check every requirement is met, and send any errors back to coding.
18
Matching a task to its PDLC stage The four PDLC stages in order; each task belongs to one: analysis lists requirements, design draws flowcharts, coding writes code, testing runs test data.
19
Pseudocode as a design method A structured, code-like way of writing an algorithm that follows set rules but does not need to run on a computer. It shows the logic of a design, not exact programming syntax.
20
Keywords in capital letters A Cambridge pseudocode keyword. All keywords, such as IF, THEN, FOR, NEXT and OUTPUT, are written in capital letters, and they cannot be used as identifier names.
21
Identifiers in Pascal case (7a) An identifier: a variable name in Pascal case. Capital letter starts each word, letters and digits only, no spaces or underscores, can't start with a digit. Not case sensitive.
22
Indentation in pseudocode Statements inside a loop or IF are moved in by four spaces, but THEN and ELSE are moved in by only two. Nested statements keep indenting, which makes the structure easy to read.
23
Comments with // (7a) Two forward slashes start a comment. Everything after // to the end of the line is ignored by the computer and only explains the code to the reader.
24
Data type keywords: INTEGER, REAL, CHAR, STRING, BOOLEAN The five data types, in order: whole number, number with a fractional part, one character, zero or more characters, TRUE or FALSE. A phone number is a STRING.
25
Writing literals in Cambridge pseudocode A fixed value written in code: a real with digits either side of the point (4.7), a CHAR in single quotes ('x'), a STRING in double quotes ("Hello"), or BOOLEAN TRUE or FALSE.
26
DECLARE a variable (7a) Creates a variable called Counter with the data type INTEGER. Form: DECLARE <identifier> : <data type>. Use one DECLARE line per variable.
27
CONSTANT declarations Names a fixed literal value that never changes while the program runs. It makes code easier to read, and you update the value in one place only.
28
Assignment with ← (7a) The ← assignment operator stores the value on its right in the variable on its left. Here 0 is stored in Counter. The value must match the variable's data type.
29
INPUT command INPUT followed by a variable name reads a value typed by the user and stores it in that variable. Use one variable per INPUT, and OUTPUT a prompt first.
30
OUTPUT command Displays text or values on screen. Text goes in quotes. Items are separated by commas, e.g. OUTPUT "You have ", Lives, " lives left". Also used for user prompts.
31
Arithmetic operators + - * / ^ (7a) Arithmetic operators: add, subtract, multiply, divide and power. ^ is worked out first, then * and /, then + and -. Brackets change or clarify the order.
32
DIV function Returns the whole-number quotient of a divided by b, discarding the fractional part. For example, DIV(10, 3) returns 3. Both a and b are integers.
33
MOD function Returns the remainder when a is divided by b. For example MOD(10, 3) gives 1. MOD(n, 2) = 0 means n is even.
34
Relational operators = < <= > >= <> Relational operators compare two values and give TRUE or FALSE: = equal, < less, <= at most, > greater, >= at least, <> not equal. Use = to compare, ← to assign.
35
Logical operators AND, OR, NOT Logical operators that combine BOOLEAN conditions: AND needs both true, OR needs at least one true, NOT reverses a condition. Use brackets in complex ones, e.g. Age >= 0 AND Age <= 120.
36
Writing precise conditions (7a) A precise condition uses a relational symbol and exact values, like Age >= 18. Words such as 'Age is old enough' or 'greater than' are too vague and lose marks.
37
LENGTH function Returns the number of characters in a string as an integer, counting spaces. LENGTH("Happy Days") returns 10. Used in length checks.
38
SUBSTRING function SUBSTRING(string, start, length) returns length characters beginning at position start. Position 1 is the first character, so this returns "Happy".
39
UCASE and LCASE functions UCASE returns a string or character in upper case, e.g. UCASE("Happy") gives "HAPPY". LCASE returns it in lower case, e.g. LCASE('W') gives 'w'.
40
IF ... THEN ... ENDIF (7a) Runs the statements between THEN and ENDIF only when the condition is TRUE. If the condition is FALSE, they are skipped. This form has no ELSE part.
41
IF ... THEN ... ELSE ... ENDIF (7a) Gives IF a second path. The THEN statements run when the condition is TRUE and the ELSE statements run when it is FALSE. Exactly one path runs, never both.
42
Nested IF statements (7a) An IF statement written inside the THEN or ELSE part of another IF. It only runs when the outer condition leads to it, and each IF needs its own ENDIF.
43
CASE OF ... ENDCASE (7a) Runs the statement beside the first value that matches the variable. An optional OTHERWISE clause, placed last, runs if nothing matches. ENDCASE closes the structure.
44
FOR ... TO ... NEXT loop (7a) Repeats the code once for each integer from 1 to 30 inclusive, up to NEXT Index. Runs once if both values are equal and not at all if the start value is bigger.
45
FOR loop with STEP (7a) Used in a FOR loop to set how much the loop variable changes each time. STEP 2 counts in twos and STEP -1 counts down. The loop stops when the value goes past the end.
46
WHILE ... DO ... ENDWHILE loop (7a) A loop that tests its condition first, then repeats its statements while the condition is TRUE. If it is FALSE at the start, the loop never runs. ENDWHILE marks the end of the loop.
47
REPEAT ... UNTIL loop (7a) A post-condition loop: its statements run at least once, then the condition is tested after them. The loop stops when the condition is TRUE.
48
Choosing between FOR, WHILE and REPEAT Use FOR when the number of repeats is known, WHILE when the loop may run zero times, and REPEAT when it must run at least once. WHILE tests first; REPEAT tests last.
49
Counting in a loop (7a) A counter is a variable set to 0 before a loop, then increased by 1 with Counter ← Counter + 1 each time the thing being counted happens.
50
Totalling in a loop (7a) A running total: set Total to 0 before the loop, then add each Value to Total on every repeat. Output Total after the loop ends.
52
Why input data is validated An automatic check by the program that input data is reasonable and in the right form. Bad data is rejected with an error message and the user is asked again, so it is never used.
53
Range check A range check tests that a value lies between the lowest and highest allowed values. The limits themselves are accepted. AND joins both limits.
54
Length check A length check tests the number of characters in an input is the required length or within a limit, using LENGTH, e.g. a password of at least 8 characters or a PIN of exactly 4.
55
Type check A validation check that tests an input is the expected data type, such as a whole number (INTEGER) for an age, and rejects letters or other wrong types.
56
Presence check A validation check that tests something has been entered, so the input is not empty. For example, Name <> "" or LENGTH(Name) > 0 makes sure a required field is not left blank.
57
Format check A check that input follows a set pattern of characters, such as a date written DD/MM/YYYY. The right pattern does not prove the data is correct, e.g. 99/99/2025 fits the pattern.
60
Re-asking for input until it is valid A REPEAT loop around INPUT that keeps asking for a value and shows an error message each time the check fails. The UNTIL condition is the valid range, so the loop ends only on valid data.
61
Combining validation checks Joins several validation checks into one condition, so the input must pass every check. Examples: presence and length together, or range and type together.
62
What validation cannot do Validation only checks data is reasonable and in the right form, so a valid value can still be wrong, e.g. age 15 typed instead of 51. Verification is also needed.
63
Choosing a validation check for a field A test matched to the field: range for age, length and type for PIN, presence for name, format for dates or postcodes, check digit for ISBN. Always justify the choice.
65
Visual check A check where a person reads the data on screen and compares it by eye with the original source to spot mistakes. It is done by a person, not the program, and can miss errors.
66
Double entry check Data is entered twice and the two entries are compared. Any difference shows a mistake, so the user must enter it again. It misses the same mistake made twice.
67
Double entry check in pseudocode Double entry check: INPUT the value twice inside a REPEAT loop and stop only when both are equal. Output a message if they do not match, so typing mistakes are caught.
68
Choosing validation or verification Validation checks data is acceptable, like an age range check. Verification checks it was typed correctly, like double entry. A scenario may need one or both.
69
Writing a validated input algorithm in pseudocode DECLARE the variable, OUTPUT a prompt, INPUT the value, OUTPUT an error message if it fails the check, and REPEAT ... UNTIL the value is acceptable.
70
Test data The input values chosen before testing, such as normal, abnormal, extreme and boundary values, used to run a program so its results can be compared with the expected results.
71
Normal test data A typical, valid value well inside the allowed limits, which the program should accept. Example: an age of 30 for a range check of 0 to 120 is accepted.
72
Abnormal test data Test data of the wrong type or outside the allowed values, such as -5 or letters for an age, or an empty input. The program should reject it.
73
Extreme test data The largest and smallest values a program should accept, such as 0 and 120 for a range of 0 to 120. They sit exactly on the limits and the expected outcome is accepted.
74
Boundary test data The largest and smallest acceptable values plus the nearest rejected values either side of each limit, e.g. 0 and -1, 120 and 121 for a range of 0 to 120.
75
Extreme data compared with boundary data Extreme data is only the accepted limit values, e.g. 1 and 100. Boundary data has those plus the rejected values next to them: 0, 1, 100 and 101 for a range of 1 to 100.
76
Suggesting test data for a range check Pick one normal, abnormal, extreme and boundary value for the range and say accept or reject. For 0 to 100: 50 normal, -5 abnormal, 100 extreme, 101 boundary.
77
Suggesting test data for length, presence and format checks Test data for a check includes values that pass and fail it: for an 8-character minimum, 8 characters is accepted, 7 is rejected, and an empty string fails a presence check.
79
Dry run of an algorithm Working through an algorithm by hand, line by line, using chosen test data as inputs and recording each step in a trace table, to see what it does and find logic errors without running it.
81
Setting up the variable columns of a trace table To set up a trace table, give each variable its own column in the order they first appear, then add a row each time a value changes. Leave unchanged cells blank.
82
The OUTPUT column of a trace table The trace table column where you write each value or message shown by an OUTPUT statement, on the row where it happens. Text in quotes is copied exactly as the output.
83
Recording user prompts and INPUT values in a trace table A prompt is written in the OUTPUT column. The value the user types for an INPUT is written in that variable's column on that step, taken from the test data.
84
Tracing assignments and arithmetic When tracing, work out the right side using the current values, then write the result in that variable's column. The old value is used first, then replaced by the new one.
85
Tracing an IF statement To trace an IF, work out if the condition is TRUE or FALSE for the current values, then follow only the THEN or ELSE path. Skipped statements get no row in the trace table.
86
Tracing a FOR loop To trace a FOR loop, give the loop variable each value from start to end in turn, run the loop body once for each value, and record every pass in its own row of the trace table.
87
Tracing WHILE and REPEAT loops Trace a loop by testing its condition each pass: WHILE tests before the body and may never run; REPEAT tests after the body so runs once at least. Stop when the loop ends.
88
Tracing counting and totalling Trace table for counting and totalling: Count and Total start at 0 in the first row, change each pass (Count only if the IF is true), and the final values are output after the loop.
89
Tracing a validation algorithm Step through a validation loop with valid and invalid inputs, recording each rejected value, the error message output and the value finally accepted in a trace table.
90
Completing a full trace table for a dry run A table for a dry run: follow the algorithm line by line with the given inputs, writing each variable, output and prompt in the order it happens, then check the final values.
91
Using a trace table to find an error In a trace table, the first row where a value differs from what you expected points to the faulty line of the algorithm. Look at that line, then suggest a correction.
92
Applying the program development life cycle to a scenario Program development life cycle: analysis, design, coding, testing. Apply it to a scenario by saying what is done at each stage and which methods and test data are used.

Just this content description: the 7a Program Development Life Cycle journey · Add 7a Program Development Life Cycle to a class →

7b Decomposition and Sub-systems (34 modules)

94
Sub-system A smaller part of a computer system that does one job within the whole system, such as the CPU, memory or storage in a computer. It is not the whole system.
95
Sub-systems made of further sub-systems Each sub-system can be split into smaller sub-systems, level by level, until every part does one simple job. A sub-system at one level is a system at the next.
98
Component parts of a problem: inputs Data that goes into a system from a user, a sensor or a file, such as a typed name, a temperature reading or a line read from a stored file.
99
Component parts of a problem: processes An action or calculation a solution carries out on its data, such as adding a total, comparing a value with a limit, sorting or searching, or making a decision.
100
Component parts of a problem: outputs The result a solution gives out, such as a message on screen, a printout, a sound or a signal that switches a device on or off.
101
Component parts of a problem: storage Data the solution must keep, in a variable, file or database, so it can be used again later. It is not the same as input or output.
102
Splitting a scenario into inputs, processes, outputs and storage Read the scenario and sort every part into input (data in), process (what is done), output (result shown) or storage (data kept). Then check nothing is missing or in the wrong group.
104
Why decomposition helps: easier to understand and solve A small part of a bigger problem. It is easier to understand and solve than the whole, so splitting a problem up makes it manageable and makes mistakes easier to find.
105
Why decomposition helps: testing each part separately Each sub-problem is tested on its own before being joined to the rest, so an error is traced to the part that causes it and only that part needs fixing, not the whole program.
106
Why decomposition helps: team work and reuse Different programmers write separate sub-problems at the same time, using their own skills, and finished parts such as a validation subroutine can be reused in other programs.
107
Program development life cycle The four ordered stages of building a program: analysis (what is needed), design (plan it), coding (write it) and testing (check it works).
108
The analysis stage: problem and requirements The first stage of the program development life cycle: identify the problem and list what the solution must do, using abstraction and decomposition, before any design starts.
109
Abstraction (7b) Keeping only the detail that matters for the problem and hiding the rest, like a tube map showing stations and lines but not exact distances.
110
Deciding which details to keep and which to ignore Keep only the details the solution needs to work and ignore the rest. A library system needs the book title and borrower, not the book's colour. Too few details fails; too many makes it harder.
111
Applying abstraction to a scenario Read the scenario, list the details the solution needs and cross out the rest, saying 'because' for each choice (e.g. a bus app keeps times, not bus colour).
113
Structure diagram A diagram with the whole problem in a top box, joined by lines to lower boxes for each sub-problem, in levels. It shows the parts of the problem, not the order of the steps.
114
Drawing a structure diagram from a scenario Name the whole problem in the top box, then split it into sub-problems level by level until each box is one simple task. Use clear box names.
115
Completing and reading a structure diagram Read the given boxes top down, then fill each gap with the sub-problem its parent box needs, so the sub-boxes together make up the parent. Ignore boxes that do not belong.
117
Choosing a design method: structure diagram, flowchart or pseudocode Shows the parts of a solution as boxes. Flowcharts (pictures) and pseudocode (text) then show the steps of each box in order. Draw the structure diagram first.
118
Cambridge flowchart symbols (7b) A fixed shape showing one step in a flowchart: oval start/end, arrow flow, rectangle process, parallelogram input/output, diamond decision, double-sided rectangle subroutine.
123
The subroutine symbol in a flowchart A rectangle with double side lines. It stands for a call to a subroutine whose steps are drawn in a separate flowchart, which keeps the main flowchart short.
124
Turning a structure diagram into a main flowchart and sub-flowcharts A flowchart that calls each sub-problem from the structure diagram with a subroutine symbol. Each sub-problem then gets its own separate flowchart.
126
Cambridge pseudocode: keywords in capitals and indentation Cambridge pseudocode writes keywords like INPUT, OUTPUT and IF in capital letters, puts one statement on each line, and indents the statements inside IF and loops.
127
Pseudocode assignment: ← The ← symbol is assignment: it stores the value on its right in the variable on its left. Total ← 0 sets Total to 0. Total ← Total + Score adds Score to Total.
128
Pseudocode INPUT and OUTPUT INPUT reads a value from the user into the variable Name. OUTPUT displays a value or message on screen, such as OUTPUT "Hello" or OUTPUT Name.
129
Pseudocode IF ... THEN ... ELSE ... ENDIF Runs the indented lines after THEN if the condition is true, otherwise runs the ELSE lines. ENDIF closes the construct and sits at the same indent as IF. ELSE is optional.
130
Pseudocode FOR ... TO ... NEXT loop A count-controlled loop that repeats the indented statements a fixed number of times, with Count going from 1 to 10. NEXT Count closes the loop and moves Count up by 1.
131
Pseudocode WHILE ... DO ... ENDWHILE and REPEAT ... UNTIL A loop that tests its condition before each repeat, so it may run 0 times. REPEAT ... UNTIL runs the body first and tests after, so it always runs at least once.
133
Pseudocode PROCEDURE ... ENDPROCEDURE and CALL Defines a named block of pseudocode for one sub-problem. It does not return a value. The block only runs when you write CALL Name() in the main program.
134
Pseudocode FUNCTION ... RETURNS ... RETURN ... ENDFUNCTION Starts a function that takes a typed parameter and RETURNS a value of the stated type. RETURN sends the value back, ENDFUNCTION closes it, and you can call it inside an expression.
136
Writing a main program that calls one procedure per sub-problem Runs a procedure. A main program is a short list of CALL lines, one per sub-problem from the structure diagram, in the right order, with no detail inside it.
137
Turning a structure diagram into pseudocode Each box in a structure diagram becomes a PROCEDURE or FUNCTION named after the box. A box with sub-boxes uses CALL statements to run them. Check that every box has code.
138
Constructing a full solution: decompose, draw and write Abstract the scenario, split it into inputs, processes, outputs and storage, draw a structure diagram, then write a flowchart or pseudocode for each part and check it against the requirements.
139
Writing exam answers about decomposition and abstraction Uses key terms (sub-system, decomposition, abstraction, input, process, output, storage) correctly and gives a reason for each point, for example by using the word 'because'.

Just this content description: the 7b Decomposition and Sub-systems journey · Add 7b Decomposition and Sub-systems to a class →

7c Pseudocode and Flowcharts (92 modules)

140
Pseudocode, flowcharts and program code Cambridge's fixed format for planning an algorithm before it is written as program code. Paper 2 answers must use it, except the 15-mark question, which allows Python, VB or Java.
141
Keywords in upper case IF is a pseudocode keyword. All keywords (IF, ENDIF, WHILE, OUTPUT) are written in upper case and never used as identifier names. Lower case, such as if, is a presentation error.
142
Identifiers in Pascal case (7c) An identifier in Pascal case: a variable or constant name using only letters and digits, starting with a capital, with each word capitalised and no spaces or underscores.
143
Indenting statements by four spaces Indent every statement inside a FOR, WHILE or REPEAT loop by 4 spaces. Nested loops add 4 more; wrapped continuation lines use 2. An unindented loop body is a presentation error.
144
Comments with // (7c) Starts a comment that runs to the end of the line. It explains the code to the reader but is not part of the algorithm, so it is ignored when run.
145
Basic data types in pseudocode The five basic pseudocode data types: whole numbers, decimals, a single character, text of any length, and TRUE or FALSE. A phone number should be a STRING.
146
Writing literals in pseudocode Literals have fixed forms: CHAR in single quotes, STRING in double quotes, REAL with a digit each side of the point, BOOLEAN as TRUE or FALSE in capitals.
147
DECLARE a variable (7c) Creates a variable named Counter and states its data type (INTEGER) before it is used. The format is DECLARE <identifier> : <data type>, with a space on each side of the colon.
148
CONSTANT Names a value set once with a literal. It never changes, needs no DECLARE, and can be updated in one place.
149
Assignment with ← (7c) Assignment stores the value on the right of ← in the variable on the left. The value must match the variable's data type, e.g. Counter ← Counter + 1.
150
Assignment ← versus comparison = ← stores a value in a variable, so Score ← 5 saves 5 in Score. = only tests if two values are equal, as in IF Score = 5, and gives TRUE or FALSE. <> tests not equal.
151
Arithmetic operators + - * / ^ (7c) Pseudocode arithmetic operators: add, subtract, multiply, divide and ^ for power. Power, * and / are worked out before + and -. Division always gives a REAL result.
152
DIV and MOD DIV(a, b) gives the whole-number part of a divided by b, so DIV(10, 3) is 3. MOD(a, b) gives the remainder, so MOD(10, 3) is 1. Both take integers.
153
Brackets in pseudocode expressions Brackets force the work inside to be done first, so A and B are added before dividing by 2. Without them, A + B / 2 divides B by 2 first. Use them in sums and AND/OR conditions.
154
Relational operators Relational operators compare two values and give a BOOLEAN result (TRUE or FALSE). = equal, <> not equal, < less than, <= less or equal, > greater than, >= greater or equal.
155
Writing precise conditions (7c) Write a condition with symbols such as >=, <> and =, not words. Age >= 18 is correct; 'Age is 18 or more' is not accepted. This applies in pseudocode and flowcharts.
156
Logical operators AND, OR and NOT AND is TRUE only when both conditions are TRUE. OR is TRUE when at least one is TRUE. NOT reverses a BOOLEAN value. Use brackets to make complex conditions clear.
157
Writing a range condition precisely A range check joins two comparisons with AND, so a value is valid only if both are true. Never chain them like 0 <= Mark <= 100. Use OR to test for values outside the range.
158
INPUT INPUT followed by a variable name reads a value typed by the user and stores it in that variable. Use one variable per INPUT, and OUTPUT a prompt first.
159
OUTPUT Displays text in double quotes, variable values or expressions on screen. Several values are separated by commas, e.g. OUTPUT "Score: ", Score
160
Sequence Statements are carried out one after another in the order they are written, from top to bottom, so changing the order can change the result.
161
IF ... THEN ... ENDIF (7c) Runs the statements between THEN and ENDIF only when the condition is TRUE. If it is FALSE, they are skipped. Every IF must be closed with ENDIF, e.g. IF Score > 50 THEN OUTPUT "Pass" ENDIF.
162
IF ... THEN ... ELSE ... ENDIF (7c) Gives the statements that run when the IF condition is FALSE. ELSE has no condition of its own, so exactly one of the two branches (THEN or ELSE) runs.
163
Indenting THEN and ELSE by two spaces THEN and ELSE sit two spaces in from IF, on their own lines. The statements inside each go further in, and ENDIF lines up with IF. Nested IFs keep the same two-space step.
164
Nested IF statements (7c) An IF statement placed inside the THEN or ELSE part of another IF, with its own ENDIF. The inner condition is only checked when the outer one sends the program into that part.
165
CASE OF ... ENDCASE (7c) Compares one variable with a list of single values and runs the statement for the first match only. Each case is indented two spaces and the structure ends with ENDCASE.
166
OTHERWISE in a CASE statement (7c) The last clause in a CASE statement. It runs when the value matches none of the listed cases, e.g. OTHERWISE OUTPUT "Beep". Without it, nothing happens if there is no match.
167
Choosing between CASE and IF Use CASE OF to test one variable against single values, like a menu choice. Use IF for ranges, like grade boundaries, or when conditions combine several variables.
168
FOR ... TO ... NEXT Repeats the statements below once for each whole number from 1 to 30 inclusive. Index is an INTEGER that changes automatically each time. Close the loop with NEXT Index.
169
FOR loop with STEP (7c) Sets how much the FOR loop variable changes each time round. STEP 2 counts in twos and STEP -1 counts down. The loop stops when the value goes past the end value.
170
How many times a FOR loop runs The number of times a FOR loop runs. FOR i ← 1 TO 5 runs 5 times, 3 TO 3 runs once, and 5 TO 1 runs zero times because the start value is bigger than the end value.
171
WHILE ... DO ... ENDWHILE A loop that tests its condition before each pass and repeats its statements while the condition is TRUE. It may run zero times, and the body must change the condition.
172
REPEAT ... UNTIL A loop that runs its statements first, then tests the condition. It stops when the condition is TRUE, so the body always runs at least once. It has no ENDREPEAT keyword.
173
WHILE versus REPEAT WHILE tests first, so its body may never run, and it loops while the condition is TRUE. REPEAT tests after the body, so it runs at least once, and it stops when the condition is TRUE.
174
Choosing the right loop Use FOR when the number of repeats is known, WHILE when the body might run zero times (such as reading until a sentinel), and REPEAT when the body must run at least once (such as validation).
175
Nested loops in pseudocode A loop placed inside another loop. The inner loop runs completely for every pass of the outer loop, so total passes = outer passes x inner passes.
176
Selection inside a loop (7c) An IF placed inside a loop body is tested again on every pass, so each pass can take a different branch. It is often used to count items that meet a condition.
177
Declaring a 1D array Creates a fixed-length array. Its 30 elements are numbered from lower bound 1 to upper bound 30, and every element holds the same data type, here STRING.
178
Using an array element Reads or changes one array element: the array name, then one index in square brackets. The index must be between the array's lower and upper bound. StudentNames[1] ← "Ali" stores a value.
179
Looping through an array with FOR (7c) Uses the loop counter Index as the array index, so Names[Index] visits every element in turn. Each one can be read, changed, input, output or totalled.
180
Declaring and using a 2D array Declares a 2D array of characters with 3 rows and 3 columns. Reach one element with a row index then a column index, e.g. NoughtsAndCrosses[2,3] ← 'X'.
181
The standard flowchart symbols Cambridge 0478 flowcharts use only six standard shapes: terminator, process, input/output, decision, subroutine and flow line. Each shape must be drawn correctly and used for its own job.
182
Terminator symbol A rounded (oval) flowchart shape that marks the Start and the Stop of a flowchart. There is one Start, every path ends at a Stop, and no arrow goes into Start.
183
Flow line An arrow that joins two flowchart shapes and shows which step runs next. The arrowhead points the way control passes, from Start to End, and a line can loop back to repeat steps.
184
Process symbol A rectangle in a flowchart that shows one action, such as a calculation or an assignment, written inside it, e.g. Total ← Total + Mark or Count ← 0.
187
Subroutine symbol A rectangle with extra vertical lines at each side. It shows a call to a procedure or function that is drawn as a separate flowchart, with the subroutine's name written inside.
188
Writing statements inside flowchart symbols Flowchart symbols hold precise pseudocode, not sentences. Process boxes use ← statements like this, decisions use conditions like Mark >= 50, parallelograms use INPUT or OUTPUT.
190
Flowchart for IF ... THEN ... ELSE The flowchart shape for an IF. It asks a question, then the Yes path and the No path each run their own statements and rejoin before the next step.
193
Flowchart for a WHILE loop In a flowchart the decision comes first. Yes runs the body and an arrow returns to the decision. No leaves the loop to the next step. The body may run zero times.
194
Flowchart for a REPEAT loop In a flowchart, the loop body comes first, then a decision. NO goes back to the body, YES leaves the loop, so the body runs at least once.
195
Flowchart for a FOR loop Set Counter ← 1 in a process box, test Counter <= 10 in a decision, run the body on Yes, then do Counter ← Counter + 1 and flow back to the test. No leaves the loop.
198
Building a flowchart from a problem List the inputs, processes and outputs, then draw Start, the steps in order with the correct symbols, and Stop. Check every path reaches Stop, then trace it with test values.
199
Converting pseudocode to a flowchart Each pseudocode statement becomes one flowchart symbol: assignment is a process box, INPUT/OUTPUT a parallelogram, and IF or loop conditions a decision diamond.
200
Converting a flowchart to pseudocode Follow the flow lines and turn each symbol into a statement. A diamond becomes IF, a back arrow shows a loop, and you add ENDIF, NEXT, ENDWHILE or UNTIL. Write keywords in capitals.
201
Pseudocode assignment, INPUT and OUTPUT in Python Python for INPUT Age: = replaces the arrow, input() reads text, and int() turns that text into a whole number. OUTPUT Age becomes print(Age); use float() for decimals.
213
CASE as if/elif/else in Python Python has no CASE, so write it as an if/elif chain testing the same variable. The first value uses if, each other value uses elif, and OTHERWISE becomes else.
216
FOR ... TO as range() in Python Python for FOR i ← 1 TO n. range() stops before its end value, so use n + 1 to include n. A third argument is the STEP; a negative step counts down.
218
REPEAT ... UNTIL as while True with break Python's version of REPEAT ... UNTIL: the body runs at least once, then an if with break at the end stops the loop when the UNTIL condition is True.
221
Pseudocode array to Python list A pseudocode array starting at index 1 becomes a Python list starting at 0, so element Scores[i] is written scores[i - 1] in Python.
224
The purpose of an algorithm What the whole algorithm achieves, stated in one sentence, such as 'finds the largest of ten numbers'. It is not a line-by-line description. Check the OUTPUT and identifier names for clues.
225
Inputs, processes and outputs of an algorithm Every algorithm takes INPUT data, carries out processes on it (calculations, decisions, storing in variables or arrays), then gives OUTPUT results.
227
Completing a trace table for pseudocode A table used to dry-run pseudocode: one column per variable plus OUTPUT, and a new row each time a statement changes a value. INPUT values come from the question.
228
Tracing a loop in a trace table Work through the loop body once per pass, recording changed values in a new row each time. Test the condition before the body for WHILE and after it for REPEAT. Check the final row.
229
Working out the purpose from a trace Running an algorithm by hand with test values, then comparing the inputs with the final outputs to work out its purpose, such as totalling, counting or finding the largest.
230
Describing the processes in an algorithm State, in order and in plain words, what each part of the algorithm does with the data: set up variables, what the loop repeats, what the decision does, then the output.
231
Describing the processes of a loop State how many times the loop repeats or the condition it stops on, and what happens to the data each time round, e.g. each mark is added to Total.
232
Explaining a flowchart Follow the flow lines from Start, say what each symbol does and what each decision tests (Yes and No paths), then state the overall purpose.
233
Finding errors in an algorithm A mistake that breaks pseudocode rules or gives wrong results. Find it by reading the code, then trace it with test values and compare the actual output with the expected output.
234
Error: = used instead of ← Use ← to store a value, so write Total ← 0, not Total = 0. Use = only to compare, as in IF Score = 5, not IF Score ← 5. Swapping them is an error.
235
Error: missing ENDIF, NEXT, ENDWHILE or UNTIL Closing keywords that end IF, FOR, WHILE and REPEAT. Each one must match its opening statement. A missing or mismatched closing keyword is an error.
236
Error: wrong relational operator Using > instead of >= (or < instead of <=) is a logic error: the boundary value, such as Age 18, is wrongly rejected. Test the boundary value, then correct the operator.
237
Error: wrong logical operator Use OR, not AND, to catch an invalid mark. A mark cannot be below 0 and above 100 at once, so AND is never TRUE. OR is TRUE when either part is TRUE.
238
Error: variable not set to zero first Set a total or counter to 0 before the loop. If you forget, it starts from an unknown value; if you put it inside the loop, it resets every time.
239
Error: wrong loop bounds A FOR loop with the wrong start or end value runs one time too many or too few, e.g. TO 9 instead of TO 10, or starting at 0 for a 1-based array. Check the bounds with a trace table.
240
Error: loop that never ends A loop that never ends because nothing in the body changes the tested variable, or the condition can never reach its exit value.
241
Error: wrong loop type Using REPEAT when the body must sometimes not run, or WHILE when it must run at least once. REPEAT always runs once; WHILE may run zero times.
242
Error: wrong data type or undeclared variable An error caused by using a value its data type does not allow (e.g. a STRING stored in an INTEGER, or an index outside the array) or by using a variable that was never DECLAREd.
243
Errors in a flowchart A mistake in a flowchart, such as the wrong symbol shape, a missing Yes or No label, a path that never reaches Stop, or a loop arrow joining the wrong place.
244
Suggesting a correction To suggest a correction, name the wrong line or symbol, say why it is wrong, write the corrected statement, and explain what the fix changes in the algorithm's output.
246
Totalling in pseudocode Totalling builds a running total. Set Total ← 0 before the loop, add each Value to Total inside the loop, then OUTPUT Total after the loop has finished.
247
Counting in pseudocode Adds 1 to Count each time an item meets a condition. Put it inside an IF in the loop, and set Count ← 0 before the loop starts so the count begins at zero.
248
Finding the maximum and minimum in pseudocode Finds the largest value: set Max to the first value, loop through the rest, and replace Max whenever a larger value is found. The minimum works the same way using < instead.
249
Calculating an average in pseudocode An average is the total divided by the count. Work it out after the loop ends, and only when Count is not 0. Store it in a REAL variable.
250
Linear search in pseudocode Checks each array element in order from the first, comparing it with the target, until a match is found or the end of the array is reached.
252
Bubble sort in pseudocode A sort that makes repeated passes, comparing neighbouring items and swapping them using a Temp variable if they are in the wrong order, until a pass makes no swaps.
253
Tracing a standard algorithm A table with a column per variable and a row per step. Use it to test an algorithm such as total, maximum, search or bubble sort by following a short list of values by hand.
254
Reading a problem to plan an algorithm Plan before coding: read the problem, list what is input, what must be calculated or decided, and what is output. Then pick variables and spot repeats and decisions.
255
Writing an algorithm in pseudocode from a problem To write an algorithm from a problem, DECLARE variables first, then INPUT, process with IF, CASE or a loop, then OUTPUT. Check each part against the problem and use the exam format.
256
Writing an algorithm as a flowchart from a problem A diagram that solves a problem using symbols for start, input, process, decision, output and stop, joined by arrows. Label each decision Yes or No and test every path to Stop.
257
Amending an algorithm Find the part that must change for the new requirement, change only that part, then re-trace the algorithm to check the rest still works.
258
Validating input with a REPEAT loop A validation loop: it asks for INPUT again and again until the value passes the check (here a range check), so invalid data never enters the algorithm.
259
Writing exam answers about algorithms The exam word that tells you what to write: state the purpose, describe the processes, identify the error, suggest the correction, each in precise terms.

Just this content description: the 7c Pseudocode and Flowcharts journey · Add 7c Pseudocode and Flowcharts to a class →

7d Standard Methods of Solution (47 modules)

261
Cambridge 0478 pseudocode conventions Cambridge pseudocode writes keywords like IF, FOR and WHILE in capitals and indents the lines inside each structure, so the code is easy to read.
262
DECLARE and data types Creates a variable called Score with a stated data type. Types: INTEGER, REAL, STRING, CHAR, BOOLEAN. Pick a meaningful name.
263
Assignment with ← (7d) The ← arrow stores the value on its right in the variable on its left. Total ← 0 sets Total to 0. A new assignment replaces the old value. It is not the same as = used to compare.
264
INPUT and OUTPUT INPUT stores a value from the user in a variable, e.g. INPUT Number. OUTPUT shows a message or value on screen, e.g. OUTPUT "Total is ", Total. Prompt first so users know what to enter.
265
Arithmetic operators in Cambridge pseudocode Arithmetic operators: + - * / calculate with numbers, and / gives a real result. DIV gives the whole-number quotient and MOD the remainder, so 17 DIV 5 is 3 and 17 MOD 5 is 2.
266
Comparison operators Comparison operators compare two values and give TRUE or FALSE. = equal, <> not equal, < less than, > greater than, <= less than or equal, >= greater than or equal.
267
AND, OR and NOT Logic operators that combine or reverse conditions: AND needs both true, OR needs one true, NOT reverses a condition. Range test: Number >= 1 AND Number <= 10
268
IF…THEN…ENDIF (7d) Runs the indented lines between THEN and ENDIF only when the condition is TRUE. If it is FALSE, those lines are skipped. Every IF must be closed with its own ENDIF.
269
IF…THEN…ELSE…ENDIF (7d) Starts the lines that run when the IF condition is FALSE. Exactly one branch runs: THEN or ELSE, never both. ELSE has no condition of its own.
270
FOR…TO…NEXT loop (7d) Repeats the lines up to NEXT Count a fixed number of times. Count starts at 1, goes up automatically, and both the start and end values are included. STEP changes the jump.
271
WHILE…DO…ENDWHILE loop (7d) A loop that tests the condition first and repeats its body while it is TRUE. The body may run zero times, and it must change the variable or the loop never ends.
272
REPEAT…UNTIL loop (7d) A loop that runs its lines first, then checks the UNTIL condition. It stops when the condition is TRUE, so the body always runs at least once.
273
Choosing FOR, WHILE or REPEAT Use FOR when the number of repeats is known. Use WHILE (tests at the start) or REPEAT (tests at the end) when repeating depends on a condition.
274
One-dimensional arrays Creates an array called Marks: a named list of 10 items, numbered from lower bound 1 to upper bound 10. Every item must be the same data type, here INTEGER.
275
Reading and changing array elements Refers to one element of the array Marks by its index, here 3. You can read it or assign to it, e.g. Marks[3] ← 55. An index outside the array bounds causes an error.
276
Looping through an array with FOR (7d) A loop whose counter is the array index. Inside it, Marks[Index] picks each element in turn, so the loop visits every item from position 1 to 10 once.
278
Standard methods of solution A tried-and-tested algorithm for a common task, such as totalling, counting, max/min, average, linear search or bubble sort, that programmers reuse instead of inventing a new solution.
279
Totalling: how it works Totalling keeps a running sum. Set Total to 0 before the loop, add each Value to Total inside the loop, then output Total after the loop. Counting adds 1 each time instead of the value.
280
Totalling in Cambridge pseudocode Adds each new Number to the running Total every time the loop repeats. Set Total ← 0 before the loop so the total starts from zero.
281
Tracing a totalling algorithm In a trace table, this line makes the Total column grow by the new Number on every pass. Total must start at 0 before the loop, and this line must sit inside the loop.
282
Counting: how it works Counting adds 1 to a counter each time something happens. Start the counter at 0, add 1 (not the item's value), and do it for every item or only for matches.
283
Counting in Cambridge pseudocode Adds 1 to the counter variable Count each time it runs inside a loop. Set Count ← 0 before the loop starts, so Count ends up holding how many times the loop ran.
284
Counting only items that meet a condition An IF inside a loop adds 1 to Count only when an item meets the condition, so Count tallies the matching items. A total adds the item's value instead.
285
Tracing a counting algorithm In a trace table, Count goes up by 1 only on rows where the condition is TRUE. If it is FALSE, Count stays the same. The final value of Count is what the OUTPUT shows.
286
Finding the maximum: how it works Keep the largest value seen so far in Max. Start Max with the first value, then replace it whenever a later value is larger. Starting at 0 can fail if all values are negative.
287
Finding the maximum in Cambridge pseudocode Used inside a loop to compare each mark with Largest. If the mark is bigger, it replaces Largest. When the loop ends, Largest holds the biggest value in the array.
288
Finding the minimum in Cambridge pseudocode Inside a loop, this compares each item with Smallest and replaces Smallest when a lower value is found. Start Smallest as Marks[1], not 0, so the minimum is correct.
289
Tracing maximum and minimum algorithms In a trace table, Largest only changes on rows where this test is true. If Number is equal or smaller, the Largest cell stays the same as the row above. Smallest uses < instead.
290
Average: how it works The average is the total of the values divided by how many values there are. It needs both a total and a count, can be a REAL, and is not allowed when the count is zero.
291
Calculating an average in Cambridge pseudocode Divides the finished Total by Count after the loop ends, giving the mean. Declare Average as REAL. Check Count > 0 first to avoid dividing by zero.
292
Total, count, maximum, minimum and average in one loop One loop visits each item once, updating the total, count, maximum and minimum together. The average is worked out after the loop ends, as Total / Count.
293
Linear search: how it works Checks each item in a list in turn, from the start, until the target is found or the end of the list is reached. It works on unsorted data.
294
Linear search with a FOR loop and a Found flag Sets a BOOLEAN flag to FALSE before a FOR loop. The loop sets Found to TRUE if an element equals the target. After the loop, Found shows whether the target was seen.
295
Linear search that stops when the target is found Keeps searching while the target has not been found AND the end of the list has not been reached, so the loop stops early as soon as Found becomes TRUE.
296
Outputting the result of a linear search After the search loop, check the Found flag: if TRUE, output the position (Index) where the target was found, otherwise output a not-found message. Covers first, last and missing items.
297
Tracing a linear search A table that records the index, the element compared and the Found flag on each pass of a linear search, so you can follow it step by step.
298
Bubble sort: how it works A sorting method that compares neighbouring items and swaps them if in the wrong order, repeating passes until the list is sorted. The largest value bubbles to the end each pass.
299
Swapping two values with a temporary variable Saves the value of Marks[Index] in Temp so it is not lost. Marks[Index] can then be overwritten, and Temp is copied into Marks[Index + 1] to finish the swap.
300
One pass of a bubble sort One pass: a FOR loop compares each item with its neighbour and swaps them if the first is larger, so the biggest value moves to the end.
301
Bubble sort with nested FOR loops Outer loop of a bubble sort: it runs n - 1 passes. Inside it, an inner FOR loop compares neighbours and swaps them if out of order, so the whole array ends up sorted.
302
Bubble sort that stops when no swaps are made A BOOLEAN flag set to FALSE before each pass and to TRUE whenever a swap happens. The bubble sort stops when a full pass leaves it FALSE, meaning no swaps were needed and the data is sorted.
303
Tracing a bubble sort Writing out the array after every pass, showing each comparison and swap, plus the Temp and Swapped values, to see how a bubble sort puts the data in order.
305
Spotting common mistakes in standard algorithms A mistake in an algorithm's steps that lets it run but gives wrong results, e.g. a total not set to 0, a loop going past the array end, or using > instead of <.
306
Identifying the standard method a problem needs Words in a problem, like add up, how many, highest, average, find or put in order, that show which standard method to use: totalling, counting, max/min, average, search or sort.
307
Writing an algorithm for a described problem To solve a described problem, list the inputs, pick the standard method, then write it: DECLARE variables, set start values, loop through the data, and OUTPUT the result.
308
Completing a partly written algorithm Fill each missing line or value by asking what the standard method (total, count, max, search, sort) needs at that point: start value, loop bound, condition or closing keyword.
309
Dry-running an algorithm and giving its output Following an algorithm line by line with given data, recording each variable's value in a trace table, to find its output or purpose.

Just this content description: the 7d Standard Methods of Solution journey · Add 7d Standard Methods of Solution to a class →

8.1a Data Types and Variables (45 modules)

310
What a variable is A named storage location in memory whose value can change while a program runs, such as Score going from 0 to 10. Programs use it to remember values.
311
What a constant is A named value set once before the program runs that never changes, unlike a variable. Example: CONSTANT Pi ← 3.142 or CONSTANT HourlyRate ← 12.50 are fixed while the program runs.
312
Identifier rules in Cambridge pseudocode The name of a variable, constant, procedure or function. Use PascalCase: letters and digits only, no spaces or underscores, start with a capital letter, e.g. FirstName.
313
Identifiers are case insensitive Capital letters do not matter in identifiers, so Countdown and CountDown are the same name. Never use names that differ only in case as two separate variables.
314
Declaring a variable with DECLARE (8.1a) Creates a variable called Counter that can only hold whole numbers. Use DECLARE name : TYPE, with a space either side of the colon, before you use the variable.
315
Declaring CHAR and STRING variables DECLARE creates a variable and sets its type. Here Initial can hold one CHAR (a single character). Use : STRING instead for text, e.g. DECLARE FirstName : STRING.
316
Assignment with the ← operator Assignment: the value on the right of the arrow is stored in the variable on the left. Counter ← 0 stores 0 in Counter and replaces any earlier value.
317
Assigning the result of an expression The expression on the right is worked out first, then its result is stored in the variable on the left, replacing any old value that variable held.
318
Assigned value must match the variable's data type An error when a value assigned to a variable has a different data type from the one it was declared with, such as storing a name in an INTEGER variable.
319
Declaring a constant with CONSTANT Declares a named value that is set once. No DECLARE line or data type is needed: the type comes from the literal, so 6.50 makes it REAL. The value cannot change later.
320
A constant's value must be a literal A constant must be set to a literal value, such as 6.50. It cannot be given a variable, another constant or an expression like Rate * 2.
321
Why use constants in a program A named value used instead of a magic number. It makes code easier to read, and when the value changes you edit it in one place only, so no missed edits cause mistakes.
322
Choosing a variable or a constant Use CONSTANT for a value fixed while the program runs, e.g. VAT rate or pi. Use a variable (DECLARE) for a value that changes or is input, e.g. score or answer.
323
INTEGER data type The data type for a whole number with no fractional part, written in denary digits, such as 5 or -3. Used for counts like lives: DECLARE Lives : INTEGER
324
REAL data type The data type for a number that can have a fractional part, written with a digit on each side of the point, such as 4.7 or 0.3. 5 is an INTEGER but 5.0 is REAL.
325
CHAR data type The data type for exactly one character (a letter, digit or symbol), written in single quotes, such as 'x', '7' or '@'. Even '7' is a character, not a number.
326
STRING data type The data type for text: zero or more characters written between double quotes, such as "This is a string". "" is the empty string and "123" is text, not a number.
327
BOOLEAN data type A data type with only two possible values, TRUE or FALSE, written without quotes. Used for yes/no information, e.g. DECLARE GameOver : BOOLEAN
328
Telling literals of each type apart How a literal is written shows its type: digits = INTEGER, decimal point = REAL, single quotes = CHAR, double quotes = STRING, TRUE or FALSE = BOOLEAN.
329
Choosing between INTEGER and REAL Use INTEGER for values that are always whole numbers, like a count of students. Use REAL if the value could have a decimal part, like a price or an average mark.
330
Choosing between CHAR and STRING Use CHAR for a value that is always exactly one character, like a grade letter or Y/N. Use STRING for text of any length, including none, like a name or phone number.
331
Choosing a suitable data type for a value Pick INTEGER, REAL, CHAR, STRING or BOOLEAN by what the value is and what you do with it, then justify with 'because'. Eg price is REAL because it has pence.
332
Output with OUTPUT OUTPUT displays a value to the user. OUTPUT "Hello" shows the text exactly as written. OUTPUT Score shows the value stored in the variable Score.
333
Outputting several values with commas One OUTPUT command can display several values, separated by commas. Mix text in quotes with variables. Any spaces you want shown must be inside the quotes.
334
Input with INPUT Reads a value typed by the user and stores it in the variable named after INPUT (here Answer). Declare the variable first; its data type decides what can be entered.
335
Input, process, output in one short program A simple program's order: DECLARE variables, INPUT values, calculate with an assignment (←), then OUTPUT the result. Each step must come before the one that uses it.
336
Addition, subtraction, multiplication and division operators The arithmetic operators in pseudocode: + adds, - subtracts, * multiplies and / divides. Example: Answer ← Score * 100 / MaxMark stores the result in a variable.
337
Power operator ^ The power operator. Radius ^ 2 raises Radius to the power 2, meaning Radius * Radius. It is worked out before multiplication, so Pi * Radius ^ 2 squares Radius first.
338
Order of operations and brackets Brackets are worked out first, then * and / before + and -. So (a + b) / 2 adds first, then divides, giving an average. Without brackets, only b is divided by 2.
339
DIV: integer division Returns how many whole times b goes into a, discarding any remainder. DIV(10, 3) gives 3, but 10 / 3 gives 3.333. Both values are integers.
340
MOD: remainder (8.1a) MOD(a, b) gives the remainder when integer a is divided by integer b, so MOD(10, 3) is 1. A result of 0 means exact division. MOD(n, 2) is 0 for even n and 1 for odd n.
341
Using DIV and MOD together (8.1a) DIV gives how many whole groups fit in the total, MOD gives what is left over. Together they split a total into whole units plus a remainder. E.g. 135 minutes is 2 hours 15.
342
Tracing assignments to find a variable's value A table with one column per variable. Follow the program line by line and write each variable's new value after every assignment, so you can predict the final OUTPUT.
343
LENGTH: number of characters in a string Returns an INTEGER: the number of characters in the string, including spaces. LENGTH("Happy Days") returns 10 and LENGTH("") returns 0.
344
SUBSTRING: extracting part of a string Returns part of a string: length characters taken from the start position. SUBSTRING("Happy Days", 1, 5) gives "Happy". The result is always a string.
345
First character at position zero or one Position 1 is the first character in Cambridge pseudocode, so this returns the first letter. Some languages count from 0 instead, so state which numbering you use.
346
UCASE: converting to upper case UCASE(x) returns the string or CHAR x with every letter in upper case. UCASE("Happy") returns "HAPPY". The original variable only changes if you assign the result.
347
LCASE: converting to lower case Returns the text with every character in lower case, e.g. LCASE("Hi") gives "hi". The original variable is unchanged unless you assign the result to it.
348
Combining string functions Nesting string functions: the inner SUBSTRING runs first, then UCASE changes its result. This gives the first letter of Name in capitals, such as an initial.
349
Meaningful identifiers for variables and constants A name that describes what a variable or constant holds, such as TotalToPay instead of T, so the program is easy to read and maintain.
350
Meaningful identifiers for arrays, procedures and functions Each word starts with a capital. Name arrays with nouns (StudentNames); name functions and procedures with verbs (CalculateTotal, DisplayMenu) to show what they store or do.
351
Comments with // (8.1a) Starts a comment. Everything after // on that line explains the code to people and is ignored when the program runs, so it never changes what the program does.
352
Writing relevant and appropriate comments A good comment explains why a section of code exists or a tricky step, without repeating the code word for word. Put it at the same indentation as the code it describes.
353
Layout conventions for Cambridge pseudocode Pseudocode layout convention: keywords in UPPER CASE, identifiers in PascalCase, and lines inside a statement indented four spaces. Meta-variables use angled brackets, like <identifier>.
354
Writing a program with variables, constants, input and strings A complete program declares variables and a CONSTANT, reads values with INPUT, processes them with assignments, then shows results with OUTPUT, using meaningful names and // comments.

Just this content description: the 8.1a Data Types and Variables journey · Add 8.1a Data Types and Variables to a class →

8.1b Sequence, Selection and Iteration (39 modules)

356
Declaring a variable with DECLARE (8.1b) Names a variable (Count) and gives its data type (INTEGER) before use. Other types: REAL, STRING, BOOLEAN. Identifiers are capitalised with no spaces.
357
Assignment with <- The <- operator stores the value on its right in the variable on its left. Count <- 0 puts 0 into Count. It is assignment, not a test for equality.
358
INPUT and OUTPUT statements INPUT stores a value the user types into a variable. OUTPUT displays a message or value on screen. Show several items by separating them with commas.
359
Indentation and comments in pseudocode Starts a comment in Cambridge pseudocode. Statements inside a loop or IF are indented four spaces, and ELSE lines up with its IF, so the structure is easy to read.
360
Writing a sequence in Cambridge pseudocode A program made of statements like DECLARE, <-, INPUT and OUTPUT that run one after another from top to bottom, with no selection or iteration. Changing the order changes the result.
361
Arithmetic operators including DIV and MOD Arithmetic operators beside + - * /. DIV gives the whole-number quotient (17 DIV 5 = 3). MOD gives the remainder (17 MOD 5 = 2). Number MOD 2 = 0 tests for even. Brackets set the order.
362
Relational operators: = and <> = tests whether two values are equal and <> tests whether they are not equal. Each gives TRUE or FALSE. Assignment uses <- instead, not =.
363
Relational operators: <, <=, > and >= Relational operators that compare the size of two values and give TRUE or FALSE. < and > leave out the boundary value; <= and >= include it, so 50 >= 50 is TRUE but 50 > 50 is FALSE.
364
Logical operator AND AND joins two conditions and is TRUE only when both are TRUE, e.g. Age >= 13 AND Age <= 19. If either condition is FALSE, the whole condition is FALSE.
365
Logical operator OR Joins two conditions. The result is TRUE when at least one condition is TRUE, e.g. Day = "Sat" OR Day = "Sun". It is only FALSE when both conditions are FALSE.
366
Logical operator NOT A logical operator that reverses a condition: NOT TRUE is FALSE and NOT FALSE is TRUE. For example, NOT (Score >= 50) is TRUE only when Score is below 50.
368
Combining AND, OR and NOT with brackets Brackets are worked out first. Without them NOT is done first, then AND, then OR. So A OR B AND C means A OR (B AND C), and brackets change that order.
369
IF…THEN…ENDIF (8.1b) Runs the indented statements only when the condition is TRUE. If it is FALSE they are skipped. ENDIF closes the selection and lines up with IF.
370
IF…THEN…ELSE…ENDIF (8.1b) Adds a second branch that runs when the IF condition is FALSE, so exactly one of the two branches runs. ELSE has no condition of its own and lines up with its IF.
371
IF with a compound condition A compound condition joins tests with AND, OR or NOT so one IF checks several things at once. AND needs both tests true; OR needs at least one true.
372
Several alternatives with IF inside ELSE A nested IF placed inside ELSE to choose between 3+ alternatives. Conditions are tested in order, only one branch runs, and every IF needs its own ENDIF.
373
CASE OF…ENDCASE (8.1b) Compares one variable (here Choice) with a list of values, runs the statement beside the matching value, and is closed by ENDCASE.
374
OTHERWISE in a CASE statement (8.1b) The last clause of a CASE statement. It runs when the variable matches none of the listed values, e.g. OTHERWISE : OUTPUT "Invalid choice". Without it, nothing happens if no value matches.
375
CASE clauses with ranges and several statements In a CASE clause, value1 TO value2 matches a whole range, such as 1 TO 9. Indented statements under the clause all run. Ranges in one CASE must not overlap.
376
Choosing between IF and CASE Use CASE OF when one variable is matched against fixed values, like a menu choice. Use IF when you test conditions with <, > or AND/OR, like age or score tests.
377
FOR…TO…NEXT count-controlled loop A count-controlled loop that repeats the indented lines end - start + 1 times, adding 1 to the counter each time. It is closed by NEXT Count, which names the same counter.
378
STEP in a FOR loop STEP sets how much the FOR counter changes each repeat. Without STEP the counter goes up by 1. A negative STEP, such as -1, makes the counter count down.
379
Using the FOR counter inside the loop Uses the FOR counter inside the loop body. Count holds a new value on each repeat, so this outputs a times table. Never change Count inside the loop; after the loop it keeps its last value.
380
WHILE…DO…ENDWHILE pre-condition loop A pre-condition loop: the condition is tested before every repeat, so the body may run zero times. The loop keeps going while the condition is TRUE and is closed by ENDWHILE.
381
A WHILE loop ended by a rogue value Loop that repeats until the user types a rogue (sentinel) value such as -1. INPUT before the loop and again at the end of the body; the rogue value is not counted or totalled.
382
REPEAT…UNTIL post-condition loop A post-condition loop: the body runs first, then UNTIL tests the condition. It always runs at least once and stops when the condition is TRUE. There is no ENDREPEAT.
383
Converting between WHILE and REPEAT…UNTIL Reverses WHILE X < 10. WHILE loops while TRUE, UNTIL stops when TRUE, so flip the condition. REPEAT also runs its body once before the first test.
384
Choosing count-controlled, pre-condition or post-condition loops Choose FOR when the number of repeats is known, WHILE when the loop may run zero times, and REPEAT...UNTIL when the loop must run at least once.
385
Totalling in a loop (8.1b) Adds each new value to the running total inside a loop. Set Total <- 0 before the loop starts, then OUTPUT Total after the loop ends.
386
Counting in a loop (8.1b) Adds 1 to the counter each time the thing being counted happens. Set Count <- 0 before the loop, and put this inside the loop (inside an IF to count only some values).
387
Working out an average from a total and a count After the loop ends, divide the total by the count to get the mean. Check that Count > 0 first, so the program never divides by zero.
388
Input validation with REPEAT…UNTIL Ends a REPEAT loop only when Mark is valid (0 to 100). Input is asked again until it passes this range check, so the program only continues with valid data.
389
Nested selection: an IF inside an IF An IF placed inside the THEN or ELSE branch of another IF. It is only checked when that outer branch runs, and each IF needs its own ENDIF, with the inner ENDIF written first.
390
Nested selection with CASE and IF A CASE clause can hold an IF, and an IF branch can hold a CASE. Close the inner structure first with its own ENDIF or ENDCASE, then close the outer one.
391
Selection inside a loop (8.1b) An IF or CASE placed in a loop body is tested again on every repeat, so each pass can take a different branch depending on the current value.
392
Iteration inside selection A loop written inside an IF branch only runs when that branch is chosen. If the condition is FALSE, it is skipped. NEXT ends the loop first, then ENDIF ends the IF.
393
Nested iteration: a loop inside a loop A loop placed inside another loop. The inner loop completes all its repeats for every single repeat of the outer loop, so a 3 by 4 nest runs the inner body 12 times.
394
Three levels of nesting Putting one structure inside another, three levels deep. Indent each level and close them in reverse order: innermost first, e.g. ENDIF, ENDIF, then NEXT.
395
Combining sequence, selection and iteration in one algorithm Set counters to 0 first (sequence), loop to read input (iteration), use IF inside the loop to pick values to count or total (selection), then OUTPUT the result after the loop.

Just this content description: the 8.1b Sequence, Selection and Iteration journey · Add 8.1b Sequence, Selection and Iteration to a class →

8.1c Procedures and Functions (47 modules)

396
What a subroutine is A named block of code, written once, that runs whenever it is called. Procedures and functions are the two kinds, and they break a program into parts.
397
Procedure A named subroutine that does a job, like outputting a line, but does not return a value. It is called as a full statement and can have parameters or none.
398
Function A named subroutine that returns a single value to the place where it is called, so the call can be used inside an expression, such as x ← Total(2, 3).
399
Parameter An identifier in a subroutine definition that receives a value when the subroutine is called. It is used like a variable inside the subroutine and has a data type.
400
Parameters and the values passed in a call A name in the subroutine definition that holds the value given in the call while it runs. With PROCEDURE Show(Num : INTEGER), CALL Show(5) makes Num hold 5.
401
Difference between a procedure and a function Only a function has RETURNS: it gives back a value used where it is called. A procedure returns nothing and is run on its own with CALL.
402
Pascal case names for subroutines A Pascal case subroutine name: it starts with a capital letter, each word is capitalised, and it uses only letters and digits, with no spaces, no underscores and no starting digit.
403
Defining a procedure with no parameters Starts a procedure with no parameters: the keyword PROCEDURE, then its name with no brackets. Indented statements follow, and ENDPROCEDURE closes it.
404
Calling a procedure with CALL CALL followed by a procedure name runs that procedure. It is a complete statement written on its own line, e.g. CALL DefaultLine. Control returns to the next line afterwards.
405
Control passing to a subroutine and back Control passes to the subroutine, which runs its statements in order. After its last statement, control returns to the line that follows the call.
406
Defining a procedure with one parameter Defines a procedure with one parameter. In the brackets after the name, write the parameter identifier, a colon, then its data type. Size is used inside the body.
407
Calling a procedure with a value CALL runs the procedure Line and passes the value 60 in brackets into its parameter. A variable can be passed too, e.g. CALL Line(MySize). Different values give different results.
408
Procedures with two or three parameters Several parameters are separated by commas, each with its own data type. A call gives one value for each, in the same order, such as CALL Show("Sam", 14).
409
Matching argument values to parameter types and order Each value in a call must match its parameter in number, order and data type, so a STRING cannot go to an INTEGER parameter and values cannot be swapped or left out.
410
Where procedures and functions are defined Write procedures and functions at the start of the code, before the main program. The main program comes after and holds the CALL statements and function calls that use them.
411
Defining a function with no parameters Starts a function with no parameters: the name has no brackets, RETURNS gives the data type of the value sent back, and ENDFUNCTION closes the function.
412
The RETURN statement RETURN followed by a value or expression sends that value back to where the function was called, e.g. RETURN Number1 * Number1. It also ends the function.
413
Defining a function with parameters A function header lists each parameter in brackets as name:TYPE, then RETURNS and the return type. The body uses the parameters in a RETURN expression and ends with ENDFUNCTION.
414
Choosing the return data type of a function Keyword in a function header, followed by a data type such as INTEGER, REAL, STRING or BOOLEAN. The value sent back by RETURN must be of that same type.
415
Calling a function inside an expression A function call is written inside an expression, with no CALL keyword. The returned value replaces the call, then the rest of the expression is worked out.
416
Using a function call in OUTPUT Puts a function call inside OUTPUT. The function runs first, then the value it RETURNs is displayed. Text can be added: OUTPUT "Sum = ", SumSquare(10, 20).
417
Storing a function result in a variable The function runs, and the value it returns is stored in the variable on the left of the arrow. You can use that variable later. Its type must match the function's return type.
418
Using a BOOLEAN function in a condition A function that RETURNS a BOOLEAN can be called straight in an IF or WHILE condition. The call gives TRUE or FALSE, so no comparison is needed.
419
Common mistakes when calling procedures and functions A common error when SumSquare is a function. CALL is only for procedures. A function returns a value, so use it in an expression, in OUTPUT, or store it in a variable.
420
Choosing a procedure or a function for a task Use a FUNCTION when a task produces one value the program needs, such as an area; use a PROCEDURE when it only does something, such as OUTPUT a menu.
421
Local variables Creates a local variable inside a procedure or function, e.g. DECLARE Length : INTEGER. It exists only while the subroutine runs and cannot be used in the main program.
422
Global variables A variable declared outside every subroutine, so the main program and any procedure or function can use and change it. It exists for the whole program.
423
Local compared with global variables A local variable is declared inside a subroutine and only exists and works there while it runs. A global variable is declared outside and can be used anywhere in the program all the time.
424
Why local variables are preferred A variable declared inside a subroutine. It keeps the subroutine self-contained, so changing it cannot accidentally alter other parts of the program, and the subroutine is easier to test alone.
425
Writing a short program with a procedure and a function The section after all procedure and function definitions. It calls them in order, using CALL for procedures and function calls inside expressions or OUTPUT.
426
Tracing a program that calls a procedure A table used to trace a call: record the value given to each parameter, follow the procedure's statements, then return to the next line of the main program.
427
Tracing a program that calls a function Tracing a call: follow the function's statements to RETURN, then replace the call with the returned value (here 500) and finish evaluating the expression.
428
Finding and fixing errors in subroutine code Finding and fixing errors by checking a subroutine's header, parameter types, RETURN, CALL, end keyword and variable scope against the syntax rules.
429
Library routines A ready-made subroutine supplied with the language that you can call without writing it, such as ROUND, RANDOM or LENGTH. It saves time and avoids errors.
430
DIV: whole-number quotient Divides a by b and returns only the whole number part, discarding any remainder. DIV(10, 3) returns 3, so it counts how many whole groups of 3 fit into 10.
431
MOD: remainder (8.1c) Returns the remainder left when a is divided by b. MOD(10, 3) is 1. The result is 0 when b divides a exactly. Example: MOD(130, 60) gives the 10 leftover minutes.
432
Using DIV and MOD together (8.1c) Use DIV and MOD on the same two numbers to split a value. DIV gives the whole units (2 hours) and MOD gives what is left over (30 minutes). Check: DIV * b + MOD gives a back.
433
ROUND: rounding to decimal places Library routine that returns value rounded to the given number of decimal places. ROUND(3.14159, 2) gives 3.14. If places is 0, the result is a whole number.
434
RANDOM: a random number between 0 and 1 A library routine with empty brackets that returns a random REAL number from 0 to 1 inclusive, a different value each time it is called. Store it, e.g. Num ← RANDOM()
435
Random whole numbers with ROUND and RANDOM Gives a random whole number from 0 to 6. RANDOM() gives a decimal from 0 to 1, times 6 stretches it, and ROUND(..., 0) turns it into a whole number.
436
Library routines inside your own subroutines Your own subroutine can call a library routine such as ROUND, MOD, DIV or RANDOM in its statements and use the value it gives back, for example in a RETURN.
437
Comments above a subroutine Starts a comment. Put one on the line before a procedure or function to say what it does and what its parameters are. The computer ignores comments.
438
Reuse: write once, call many times Calls the Line procedure written once, so the same code is reused many times with different parameters instead of being repeated in the program.
439
Changing code in one place Code kept in one subroutine is edited once, so every CALL gets the update. Repeated copies must each be changed, and missing one gives inconsistent results.
440
Subroutines make programs easier to test and read A program split into small named subroutines. Each one can be tested alone and read quickly, so errors are easier to find and the whole program is easier to understand.
441
Explaining how subroutines make a program easier to maintain A full maintenance answer names a benefit of subroutines, such as one place to change, then uses because to give the reason, ideally with an example from the program, not just 'it is easier'.
442
Writing exam answers about procedures and functions Keyword in a FUNCTION header giving the data type of the value sent back, e.g. FUNCTION Area(r : REAL) RETURNS REAL. End with ENDFUNCTION. Never use CALL for a function.

Just this content description: the 8.1c Procedures and Functions journey · Add 8.1c Procedures and Functions to a class →

8.2 Arrays (40 modules)

443
Why arrays are used An array stores many values of the same type under one name, so you need one array instead of many variables. An index reaches each value, and loops can process them all.
444
Array, element and index A fixed-length structure of elements; each element holds one value and is reached by its index, the position number in square brackets, such as Marks[3].
445
Lower bound and upper bound In ARRAY[l:u], l is the lower bound (index of the first element) and u is the upper bound (index of the last). Here the lower bound is 1 and the upper bound is 30.
446
Arrays have a fixed length and one data type An array has a fixed size set when it is declared, and every element must be the same data type, so STRING and INTEGER cannot be mixed in one array.
447
Declaring a 1D array: DECLARE name : ARRAY[l:u] OF type Declares a 1D array named StudentNames with indexes 1 to 30 (lower:upper), each element holding a STRING. It only sets up the array; no values are stored yet.
448
Array data types: INTEGER, REAL, CHAR, STRING, BOOLEAN The data type after OF decides what every element can hold. ARRAY[1:10] OF INTEGER holds ten whole-number scores; REAL, CHAR, STRING or BOOLEAN would hold other kinds of data.
449
Array bounds starting at zero or one The number before the colon is the lower bound, the first index. ARRAY[1:30] starts at 1, ARRAY[0:29] starts at 0. Both hold 30 elements, so always state the lower bound.
450
Working out how many elements an array holds The number of elements in a 1D array: upper bound minus lower bound plus one. ARRAY[0:9] holds 9 - 0 + 1 = 10 elements, and ARRAY[5:9] holds 5.
451
Meaningful identifiers for arrays An array name that says what its elements hold, like StudentNames not A. It must never be a keyword such as INPUT or FOR, and upper or lower case makes no difference.
452
Writing a value into an array element Stores a value in one array element using the assignment operator ←. The value must match the array's data type, and it replaces any old value already in that element.
453
Reading a value from an array element Reading an element: Name[index] in OUTPUT or an expression gives the value stored in that element. Reading only uses the value, so the element stays unchanged.
454
Using a variable as an array index A variable inside the brackets picks the element whose index matches its value. Change Index (an INTEGER) and the same statement reaches a different element of Marks.
455
Using an expression as an array index An index can be an expression like n+1. The expression is worked out first, then that element is used. It must stay within the array's bounds. Example: n=3 gives Array[4].
456
Index out of range An error caused by using an index below the lower bound or above the upper bound, so the element does not exist. Example: Marks[31] in ARRAY[1:30] or Marks[0] when the lower bound is 1.
457
Count-controlled loop: FOR … TO … NEXT A count-controlled loop. It repeats the indented statements once for each value of Index, from 1 up to 30, going up by 1 each time. NEXT Index closes the loop.
458
Setting every element with a FOR loop A loop that uses its counter as the array index, so each pass assigns a value to one element, e.g. Scores[Index] ← 0. The loop limits must match the array bounds.
459
Looping with a lower bound of zero For ARRAY[0:29], the loop must start at the lower bound 0 and end at the upper bound 29. It then visits all 30 elements and never goes outside the array.
460
Reading values into an array with INPUT in a loop Inside a FOR loop, INPUT Name[Index] stores each value the user types into the next array element, because Index changes every time the loop repeats.
461
Displaying every element with OUTPUT in a loop Inside a FOR loop, this line displays every element of the array in order. Index changes on each pass, so each pass outputs the next element, from the lower bound to the upper bound.
462
Totalling the elements of an array Adds the current element to the running total on each loop pass. Set Total ← 0 before the loop first, or the answer will be wrong. Divide by the number of elements for the average.
463
Counting elements that meet a condition An IF inside the loop tests each element and adds 1 to Count when true. Set Count to 0 before the loop. A counter counts matches; a total adds up values.
464
Finding the largest value in an array Start by assuming the first element is the largest, then compare every other element and replace Largest when a bigger one is found.
465
Searching an array for a value A loop checks every element against the wanted value. On a match, set Found to TRUE and record the index. If Found is still FALSE at the end, OUTPUT a not found message.
466
Parallel arrays Two or more arrays of the same size where the same index holds related data, e.g. StudentNames[3] and Marks[3] both describe the same student.
467
Tracing a 1D array program with a trace table A table that records the loop variable, index and array contents after each pass of a loop, so you can predict the final OUTPUT and spot errors such as off-by-one.
468
Two-dimensional array: rows and columns A table of rows and columns held in one variable. Each element needs two indexes: the first is the row (across), the second is the column (down), e.g. Marks[2, 3].
469
Declaring a 2D array: ARRAY[l1:u1, l2:u2] Declares a 2D array called Grid. The first range is the rows, the second is the columns, split by a comma. All elements share one data type, here CHAR.
470
Working out how many elements a 2D array holds The total number of elements in a 2D array. Each dimension holds upper - lower + 1 values, so ARRAY[1:3, 1:3] holds 3 * 3 = 9 and ARRAY[1:30, 1:4] holds 30 * 4 = 120.
471
Writing a value into a 2D array element Stores a value in one element of a 2D array. Give the row index first, then the column index, e.g. NoughtsAndCrosses[2,3] ← 'X' puts a CHAR in row 2, column 3.
472
Reading a value from a 2D array element Gives the value stored at that row and column of a 2D array. Use it in an expression or OUTPUT, e.g. OUTPUT NoughtsAndCrosses[2,3] shows the value at row 2, column 3.
473
Using variables as indexes in a 2D array Uses two variables as the row and column indexes, so one statement can reach any element of a 2D array. Both variables must stay within their bounds.
474
Filling a 2D array with nested FOR loops A FOR loop for the columns placed inside a FOR loop for the rows. The inner loop runs fully for each row, so every element of a 2D array is visited and given a value.
475
Reading values into a 2D array with INPUT in nested loops Inside nested FOR loops, this reads a typed value into one cell of a 2D array. The inner loop fills a whole row before the outer loop moves to the next row.
476
Displaying a 2D array with nested loops Placed inside nested FOR loops (outer loop for rows, inner loop for columns), this line displays each element of a 2D array once, in row order.
477
Totalling rows, columns and a whole 2D array Adds each element to a running total inside nested loops. Set Total to 0 first: before the loops for a grand total, or inside the outer loop for each row or column total.
478
Searching a 2D array Inside nested FOR loops, this compares each 2D array element with the wanted value; when it matches, store Row and Column as FoundRow and FoundColumn.
479
Tracing nested loops over a 2D array Tracks Row, Column and the element changed. The outer loop variable stays fixed while the inner one runs through all its values. Total passes = rows x columns.
480
Choosing a 1D or 2D array for a scenario Use a 1D array for a simple list of values. Use a 2D array when data forms a table or grid, so each value needs two indexes: a row and a column.
481
Common array mistakes in pseudocode Typical bugs: loop limits not matching ARRAY[l:u], swapped row and column indexes, a total not reset to 0, or the wrong data type stored. Check bounds, index order and starting values.
482
Writing a complete array program: declare, fill and output The pattern of a complete array program: declare the array, use a FOR loop to INPUT a value into each element, then use a second FOR loop to OUTPUT every element.

Just this content description: the 8.2 Arrays journey · Add 8.2 Arrays to a class →

8.3 File Handling (21 modules)

483
Why programs store data in a file A file keeps data on storage so it still exists after the program closes, unlike variables. The program can read it back next time it runs, such as a saved high score or a list of names.
484
File identifier: the file name as a string A file identifier is the name of the file, written as a string in double quotes with its extension, such as "FileA.txt". The same identifier is used in every file command.
485
File modes: READ and WRITE States what a program will do with an open file: READ gets data out of it, WRITE puts data into it. A file is open in only one mode at a time, chosen by what the program needs.
486
Declaring a variable to hold file data Creates a variable named LineOfText that holds text. Declare it before the file commands that use it, for example before READFILE stores a line in it.
487
OPENFILE ... FOR WRITE Opens the file Scores.txt in write mode so data can be written into it with WRITEFILE. The file must be opened before writing. Keywords are in capitals.
488
WRITE mode creates a new file and replaces old data Opens a file for writing. A new file is created if none exists. If it does exist, all its old data is erased and replaced, so check before overwriting data you need.
489
WRITEFILE: writing a single item of data Writes the value stored in a variable into an open file. Give the file name, a comma, then the variable. The file must already be open in WRITE mode.
490
WRITEFILE: writing a line of text Writes the text held in the STRING variable LineOfText into the file Names.txt as one new line. Each WRITEFILE adds one more line to the file.
491
CLOSEFILE Closes the file named in the identifier once you have finished reading or writing, so data is saved and the file is released. The name must match the one used in OPENFILE.
492
Why a file must be closed Closes an open file so its data is safely saved and the file can be opened again in a different mode, such as READ after WRITE. Use one CLOSEFILE for each OPENFILE.
493
OPENFILE ... FOR READ Opens the existing file Scores.txt in READ mode so the program can read data from it with READFILE. The file must already exist, and READ mode does not change its contents.
494
READFILE: reading a single item of data Reads one data item from the open file and stores it in the variable. The file must already be open in READ mode, and the variable's data type must match the item.
495
READFILE: reading a line of text Reads the next line of text from the open file Names.txt into the STRING variable LineOfText. Each READFILE call reads the following line. Declare the variable first.
496
Matching the variable's data type to the file data The variable used with READFILE or WRITEFILE needs a data type that suits the data: STRING for a line of text, INTEGER for a whole number. A wrong type causes errors.
498
Writing several items to a file with a FOR loop A FOR loop with INPUT and WRITEFILE inside repeats a fixed number of times, writing one item to the open file on each repeat. CLOSEFILE goes after NEXT.
499
Reading several items from a file with a FOR loop Repeats READFILE and OUTPUT 5 times to read 5 items from an open file, one per repeat, in the order written. Put CLOSEFILE after NEXT.
500
Write, close, then read the data back Open a file for WRITE, store data with WRITEFILE, then CLOSEFILE. Reopen the same file name for READ and READFILE gets the data back to use again.
501
Copying a line of text from one file to another Writes the line held in LineOfText (read earlier from FileA.txt) into FileB.txt, copying it between files. Both files must be opened first and each one closed after.
502
Tracing a file handling program A table that follows a program step by step, recording the file contents and each variable's value after every file command, until you find the final OUTPUT.
503
Common mistakes in file handling pseudocode A mistake such as using the wrong mode, missing OPENFILE or CLOSEFILE, using different file names, or opening a file FOR WRITE and wiping its old data.
504
Writing a complete file handling program in 0478 pseudocode The order of a complete file program: declare variables, open the file in the right mode, read or write the data, then close the file. Keywords are in capitals and statements are indented.

Just this content description: the 8.3 File Handling journey · Add 8.3 File Handling to a class →

9 Databases (16 modules)

506
Counting fields and records in a table A field is a column and a record is one data row. The heading row is not a record. A table with 4 fields and 6 records has 4 columns and 7 rows including the heading.
508
Character versus text fields A character field holds exactly one character, like a grade A-E or an M/F code. A text field holds a string of any length, like a name or a postcode.
519
Choosing a validation check for each field A rule that tests data on entry. Pick the one that fits each field: range for a mark, length for a phone number, presence for a required name, list for a year group.
521
Choosing a suitable primary key from a table The field chosen to identify each record. Its values must be unique and never blank, like an ID number. Names and dates of birth can repeat, so they are unsuitable.
522
Defining a single-table database from storage requirements The plan for one table: list each field the scenario needs, give it a data type and any validation, and choose a primary key so the table can hold every record.
525
Field order in the output of a SELECT The output has only the fields named, as columns in the order written after SELECT, with a heading row of field names and one row per record kept (all records if there is no WHERE).
528
WHERE on text, Boolean, character and date fields The value in a WHERE condition must match the field's data type: text and characters go in quotes, numbers do not, and Boolean fields use TRUE or FALSE, e.g. Member = TRUE.
530
Mixing AND and OR with brackets in a WHERE clause Brackets make SQL work out the OR first, then the AND. A record must meet C and also A or B. Moving the brackets, as in A OR (B AND C), can return different records.
532
Clause order in a full SQL query The order of clauses in a full SQL query: SELECT, FROM, WHERE, then ORDER BY. WHERE filters the rows first, then ORDER BY sorts the rows that are left.
533
SQL SUM function Adds up all the values in a numeric field and returns one total, e.g. SELECT SUM(Score) FROM Results; gives one row. It only works on numbers.
534
SQL COUNT function SQL function that counts records. SELECT COUNT(*) FROM Students; outputs one row with the number of records in the table. It counts rows, whereas SUM adds up values.
535
SUM and COUNT with a WHERE condition WHERE filters the records first, then COUNT or SUM works only on the matching ones. This counts members from Leeds. If no record matches, COUNT gives 0.
536
Working out the output of an SQL statement To find a query's output, first keep the rows that pass WHERE, then sort them with ORDER BY, then show only the SELECT fields or the SUM or COUNT result.
537
Completing an SQL script Completing an SQL script: read the task, then fill the gap with the right field, WHERE condition, ASC or DESC, AND or OR, or SUM or COUNT so the query returns exactly what is asked.
538
Writing an SQL query from a requirement Turn a request into one SQL statement: pick fields after SELECT, the table after FROM, conditions in WHERE, sort with ORDER BY, and use SUM or COUNT for totals and how many.
539
Common mistakes in SQL scripts A mistake in an SQL script, such as text without quotes, > instead of >=, AND instead of OR, clauses in the wrong order, a missing table after FROM or a missing semicolon.

Just this content description: the 9 Databases journey · Add 9 Databases to a class →

10 Boolean Logic (38 modules)

542
What a logic gate is An electronic component that takes one or two binary inputs (0 or 1) and gives one binary output (0 or 1) by a fixed rule. Processors are built from many gates.
543
Labelling inputs and the output: A, B, C and X In a logic circuit, the inputs are labelled with capital letters A, B and C on the left, and the single output is labelled X on the right.
544
Truth table layout for two inputs A table listing every input combination in its rows, with the output in the last column. Two inputs give 2^2 = 4 rows, in the order 00, 01, 10, 11.
545
The NOT gate A logic gate with one input that outputs the opposite value: 0 becomes 1 and 1 becomes 0. It is drawn as a triangle with a small circle and written X = NOT A.
546
The AND gate A logic gate with two inputs that outputs 1 only when both inputs are 1; otherwise it outputs 0. Written X = A AND B, drawn as a D shape, with truth table output 0 0 0 1.
547
The OR gate The OR gate has two inputs, A and B. Its output X is 1 when at least one input is 1, and 0 only when both are 0. Its truth table output column is 0 1 1 1.
549
Number of inputs on each gate NOT has exactly one input. AND, OR, NAND, NOR and XOR each have exactly two inputs. No three-input gates in this course, so join two gates for three inputs.
550
The NAND gate A gate with two inputs that outputs 0 only when both inputs are 1. It is the opposite of AND (AND followed by NOT). Its truth table output is 1 1 1 0. Written X = A NAND B.
551
The NOR gate The NOR gate: output X is 1 only when both inputs A and B are 0. It is OR followed by NOT, so the truth table output is 1 0 0 0. Its symbol is OR with a small circle.
552
The XOR (EOR) gate The XOR (exclusive OR, or EOR) gate has two inputs and outputs 1 only when the inputs are different. Its truth table output is 0 1 1 0. Its symbol is the OR shape with an extra curve at the input.
553
OR versus XOR: the row where both inputs are 1 Exclusive OR: outputs 1 when exactly one input is 1. When A and B are both 1 it outputs 0, but OR outputs 1 in that row. XOR means one or the other, but not both.
554
Telling similar gate symbols apart A small circle on a gate's output means NOT: AND becomes NAND and OR becomes NOR. XOR has no circle; its symbol is OR with an extra curved line at the input side.
555
Identifying a gate from its truth table output Read the output column for rows 00, 01, 10, 11 to name the gate: AND 0001, OR 0111, NAND 1110, NOR 1000, XOR 0110.
556
Logic expression for a single gate A logic expression for one gate: write the output X, an equals sign, then the input letters joined by the gate name in capitals, such as X = NOT A or X = A XOR B.
557
Brackets in logic expressions Brackets show which gate is worked out first. Here A AND B is done first, then its result goes into OR with C. A AND (B OR C) uses the same letters but gives a different output.
558
Where NOT applies in an expression NOT before a bracket flips the whole bracket's result. In (NOT A) AND B, NOT flips only input A, so NOT (A AND B) gives different results.
559
Truth table layout for three inputs A three-input truth table has 8 rows (2 x 2 x 2) in binary counting order from 000 to 111, with A changing slowest and C changing fastest.
560
Completing a truth table from an expression: one gate Complete the truth table row by row: apply the gate rule to the input values A and B in each row and write the result in column X. AND gives 1 only when both inputs are 1.
561
Intermediate columns in a truth table An extra truth table column for a bracket or gate output, such as P = A AND B. It is filled in first, so the final output X can be worked out step by step from earlier columns.
562
Completing a truth table from an expression: three inputs Fill all 8 rows of A, B and C: work out the bracket (A AND B) in an extra column first, then combine it with C using OR to get output X.
563
Logic circuit: gates, wires and junctions A diagram of logic gates joined by wires. Inputs are on the left, the output is on the right, and each wire carries 0 or 1. A dot where a wire splits is a junction.
564
Tracing one input combination through a circuit Write the input values on the wires, then work gate by gate from left to right, writing each gate's output on its output wire until you reach the final output X.
565
Completing a truth table from a logic circuit Follow one row of input values through each gate in the circuit, write each gate's output in an extra column, then copy the final value of X into the truth table.
566
Writing a logic expression from a logic circuit: one gate Name the gate, then write X = with the input letters and the gate name, e.g. an AND gate with inputs A and B is X = A AND B. NOT has one input: X = NOT A.
567
Writing a logic expression from a logic circuit: several gates Write each gate's expression from left to right, putting each earlier gate in brackets as an input to the next gate. The final gate is the outermost operator.
568
Creating a logic circuit from an expression Draw one gate per operator: the bracket (A AND B) becomes an AND gate first, and its output feeds the final OR gate along with C to give X.
569
Drawing circuits without simplification Draw every gate in the given expression, one for each operator, even if a shorter circuit has the same truth table. Never combine or remove gates.
570
Drawing wires, junctions and crossings neatly A dot drawn where wires join, so one input can feed two gates. Wires that cross with no dot are not connected. Draw inputs on the left and the output on the right.
571
Words in a problem statement and the gates they describe Words in a problem statement point to a gate: both/and = AND, either/or = OR, not = NOT, neither...nor = NOR, not both = NAND, only one of = XOR.
572
Writing a logic expression from a problem statement Give each condition a letter (A, B, C), turn key words like AND, OR and NOT into gates, and use brackets to group parts so that X matches the wording of the statement.
573
Creating a logic circuit from a problem statement Turn the problem statement into a logic expression first, then draw one gate for each operator to build the circuit. Use inputs A, B, C (up to three) and one output X. Do not simplify.
574
Completing a truth table from a problem statement Write the problem statement as an expression like this, then find X for every row of the table: put 1 where the statement is true and 0 where it is false.
575
Writing a logic expression from a truth table To write an expression from a truth table, take each row with output 1 and join its inputs with AND, adding NOT to any input that is 0. Then join those rows with OR.
576
Creating a logic circuit from a truth table To draw a circuit from a truth table, write the expression that gives the X output column, then draw one gate for each operator in it. Do not simplify the expression.
577
Limits on circuit size: three inputs and one output A circuit here has at most three inputs (A, B, C) and exactly one output X. With 3 inputs the truth table has 8 rows (2 x 2 x 2). Gates with two inputs can be combined to handle the third input.
578
Checking that a circuit, expression and truth table agree A circuit, expression and truth table are equivalent when each gives the same output X for the same inputs. Check by working out X row by row in each one and comparing the results.
579
Common mistakes with logic gates, expressions and truth tables Mixing up NAND/AND or OR/XOR, rows out of binary order, NOT on the wrong part, missing brackets or columns, wrong input counts, or simplifying a circuit that must be drawn as given.
580
Writing exam answers about Boolean logic A full-mark answer uses capital gate names, labelled inputs A, B, C and output X, correct brackets and a complete truth table with every row filled.

Just this content description: the 10 Boolean Logic journey · Add 10 Boolean Logic to a class →

Printable IGCSE Computer Science Paper 2 Crosswords & Word Searches

Built from the key terms of each block of modules, every one with a full answer key. All free printables →

✎
Crossword: 7a Program Development Life Cycle (Modules 1–16) 10 clues · The program development life cycle, The analysis stage, Identifying the problem, Abstraction (7a) and more
✎
Crossword: 7a Program Development Life Cycle (Modules 17–26) 10 clues · The testing stage, Matching a task to its PDLC stage, Pseudocode as a design method, Keywords in capital letters and more
✎
Crossword: 7a Program Development Life Cycle (Modules 27–36) 10 clues · CONSTANT declarations, Assignment with ← (7a), INPUT command, OUTPUT command and more
✎
Crossword: 7a Program Development Life Cycle (Modules 37–46) 10 clues · LENGTH function, SUBSTRING function, UCASE and LCASE functions, IF ... THEN ... ENDIF (7a) and more
✎
Crossword: 7a Program Development Life Cycle (Modules 47–57) 10 clues · REPEAT ... UNTIL loop (7a), Choosing between FOR, WHILE and REPEAT, Counting in a loop (7a), Totalling in a loop (7a) and more
✎
Crossword: 7a Program Development Life Cycle (Modules 60–70) 10 clues · Re-asking for input until it is valid, Combining validation checks, What validation cannot do, Choosing a validation check for a field and more
✎
Crossword: 7a Program Development Life Cycle (Modules 71–82) 10 clues · Normal test data, Abnormal test data, Extreme test data, Boundary test data and more
✎
Crossword: 7a Program Development Life Cycle (Modules 83–92) 10 clues · Recording user prompts and INPUT values in a trace table, Tracing assignments and arithmetic, Tracing an IF statement, Tracing a FOR loop and more
✎
Crossword: 7b Decomposition and Sub-systems (Modules 94–106) 10 clues · Sub-system, Sub-systems made of further sub-systems, Component parts of a problem: inputs, Component parts of a problem: processes and more
✎
Crossword: 7b Decomposition and Sub-systems (Modules 107–118) 10 clues · Program development life cycle, The analysis stage: problem and requirements, Abstraction (7b), Deciding which details to keep and which to ignore and more
✎
Crossword: 7b Decomposition and Sub-systems (Modules 123–134) 10 clues · The subroutine symbol in a flowchart, Turning a structure diagram into a main flowchart and sub-flowcharts, Cambridge pseudocode: keywords in capitals and indentation, Pseudocode assignment: ← and more
✎
Crossword: 7b Decomposition and Sub-systems and 7c Pseudocode and Flowcharts (Modules 136–145) 10 clues · Writing a main program that calls one procedure per sub-problem, Turning a structure diagram into pseudocode, Constructing a full solution: decompose, draw and write, Writing exam answers about decomposition and abstraction and more
✎
Crossword: 7c Pseudocode and Flowcharts (Modules 146–155) 10 clues · Writing literals in pseudocode, DECLARE a variable (7c), CONSTANT, Assignment with ← (7c) and more
✎
Crossword: 7c Pseudocode and Flowcharts (Modules 156–165) 10 clues · Logical operators AND, OR and NOT, Writing a range condition precisely, INPUT, OUTPUT and more
✎
Crossword: 7c Pseudocode and Flowcharts (Modules 166–175) 10 clues · OTHERWISE in a CASE statement (7c), Choosing between CASE and IF, FOR ... TO ... NEXT, FOR loop with STEP (7c) and more
✎
Crossword: 7c Pseudocode and Flowcharts (Modules 176–187) 10 clues · Selection inside a loop (7c), Declaring a 1D array, Using an array element, Looping through an array with FOR (7c) and more
✎
Crossword: 7c Pseudocode and Flowcharts (Modules 188–213) 10 clues · Writing statements inside flowchart symbols, Flowchart for IF ... THEN ... ELSE, Flowchart for a WHILE loop, Flowchart for a REPEAT loop and more
✎
Crossword: 7c Pseudocode and Flowcharts (Modules 216–231) 10 clues · FOR ... TO as range() in Python, REPEAT ... UNTIL as while True with break, Pseudocode array to Python list, The purpose of an algorithm and more
✎
Crossword: 7c Pseudocode and Flowcharts (Modules 232–241) 10 clues · Explaining a flowchart, Finding errors in an algorithm, Error: = used instead of ←, Error: missing ENDIF, NEXT, ENDWHILE or UNTIL and more
✎
Crossword: 7c Pseudocode and Flowcharts (Modules 242–253) 10 clues · Error: wrong data type or undeclared variable, Errors in a flowchart, Suggesting a correction, Totalling in pseudocode and more
✎
Crossword: 7c Pseudocode and Flowcharts and 7d Standard Methods of Solution (Modules 254–264) 10 clues · Reading a problem to plan an algorithm, Writing an algorithm in pseudocode from a problem, Writing an algorithm as a flowchart from a problem, Amending an algorithm and more
✎
Crossword: 7d Standard Methods of Solution (Modules 265–274) 10 clues · Arithmetic operators in Cambridge pseudocode, Comparison operators, AND, OR and NOT, IF…THEN…ENDIF (7d) and more
✎
Crossword: 7d Standard Methods of Solution (Modules 275–285) 10 clues · Reading and changing array elements, Looping through an array with FOR (7d), Standard methods of solution, Totalling: how it works and more
✎
Crossword: 7d Standard Methods of Solution (Modules 286–295) 10 clues · Finding the maximum: how it works, Finding the maximum in Cambridge pseudocode, Finding the minimum in Cambridge pseudocode, Tracing maximum and minimum algorithms and more
✎
Crossword: 7d Standard Methods of Solution (Modules 296–306) 10 clues · Outputting the result of a linear search, Tracing a linear search, Bubble sort: how it works, Swapping two values with a temporary variable and more
✎
Crossword: 7d Standard Methods of Solution and 8.1a Data Types and Variables (Modules 307–316) 10 clues · Writing an algorithm for a described problem, Completing a partly written algorithm, Dry-running an algorithm and giving its output, What a variable is and more
✎
Crossword: 8.1a Data Types and Variables (Modules 317–326) 10 clues · Assigning the result of an expression, Assigned value must match the variable's data type, Declaring a constant with CONSTANT, A constant's value must be a literal and more
✎
Crossword: 8.1a Data Types and Variables (Modules 327–336) 10 clues · BOOLEAN data type, Telling literals of each type apart, Choosing between INTEGER and REAL, Choosing between CHAR and STRING and more
✎
Crossword: 8.1a Data Types and Variables (Modules 337–346) 10 clues · Power operator ^, Order of operations and brackets, DIV: integer division, MOD: remainder (8.1a) and more
✎
Crossword: 8.1a Data Types and Variables and 8.1b Sequence, Selection and Iteration (Modules 347–357) 10 clues · LCASE: converting to lower case, Combining string functions, Meaningful identifiers for variables and constants, Meaningful identifiers for arrays, procedures and functions and more
✎
Crossword: 8.1b Sequence, Selection and Iteration (Modules 358–368) 6 clues · INPUT and OUTPUT statements, Indentation and comments in pseudocode, Writing a sequence in Cambridge pseudocode, Arithmetic operators including DIV and MOD and more
✎
Crossword: 8.1b Sequence, Selection and Iteration (Modules 369–378) 10 clues · IF…THEN…ENDIF (8.1b), IF…THEN…ELSE…ENDIF (8.1b), IF with a compound condition, Several alternatives with IF inside ELSE and more
✎
Crossword: 8.1b Sequence, Selection and Iteration (Modules 379–388) 9 clues · Using the FOR counter inside the loop, WHILE…DO…ENDWHILE pre-condition loop, A WHILE loop ended by a rogue value, REPEAT…UNTIL post-condition loop and more
✎
Crossword: 8.1b Sequence, Selection and Iteration and 8.1c Procedures and Functions (Modules 389–398) 10 clues · Nested selection: an IF inside an IF, Nested selection with CASE and IF, Selection inside a loop (8.1b), Iteration inside selection and more
✎
Crossword: 8.1c Procedures and Functions (Modules 399–408) 10 clues · Parameter, Parameters and the values passed in a call, Difference between a procedure and a function, Pascal case names for subroutines and more
✎
Crossword: 8.1c Procedures and Functions (Modules 409–418) 10 clues · Matching argument values to parameter types and order, Where procedures and functions are defined, Defining a function with no parameters, The RETURN statement and more
✎
Crossword: 8.1c Procedures and Functions (Modules 419–428) 10 clues · Common mistakes when calling procedures and functions, Choosing a procedure or a function for a task, Local variables, Global variables and more
✎
Crossword: 8.1c Procedures and Functions (Modules 429–438) 10 clues · Library routines, DIV: whole-number quotient, MOD: remainder (8.1c), Using DIV and MOD together (8.1c) and more
✎
Crossword: 8.1c Procedures and Functions and 8.2 Arrays (Modules 439–448) 10 clues · Changing code in one place, Subroutines make programs easier to test and read, Explaining how subroutines make a program easier to maintain, Writing exam answers about procedures and functions and more
✎
Crossword: 8.2 Arrays (Modules 449–458) 10 clues · Array bounds starting at zero or one, Working out how many elements an array holds, Meaningful identifiers for arrays, Writing a value into an array element and more
✎
Crossword: 8.2 Arrays (Modules 459–468) 10 clues · Looping with a lower bound of zero, Reading values into an array with INPUT in a loop, Displaying every element with OUTPUT in a loop, Totalling the elements of an array and more
✎
Crossword: 8.2 Arrays (Modules 469–478) 10 clues · Declaring a 2D array: ARRAY[l1:u1, l2:u2], Working out how many elements a 2D array holds, Writing a value into a 2D array element, Reading a value from a 2D array element and more
✎
Crossword: 8.2 Arrays and 8.3 File Handling (Modules 479–488) 10 clues · Tracing nested loops over a 2D array, Choosing a 1D or 2D array for a scenario, Common array mistakes in pseudocode, Writing a complete array program: declare, fill and output and more
✎
Crossword: 8.3 File Handling (Modules 489–499) 10 clues · WRITEFILE: writing a single item of data, WRITEFILE: writing a line of text, CLOSEFILE, Why a file must be closed and more
✎
Crossword: 8.3 File Handling and 9 Databases (Modules 500–522) 10 clues · Write, close, then read the data back, Copying a line of text from one file to another, Tracing a file handling program, Common mistakes in file handling pseudocode and more
✎
Crossword: 9 Databases (Modules 525–538) 10 clues · Field order in the output of a SELECT, WHERE on text, Boolean, character and date fields, Mixing AND and OR with brackets in a WHERE clause, Clause order in a full SQL query and more
✎
Crossword: 9 Databases and 10 Boolean Logic (Modules 539–551) 10 clues · Common mistakes in SQL scripts, What a logic gate is, Labelling inputs and the output: A, B, C and X, Truth table layout for two inputs and more
✎
Crossword: 10 Boolean Logic (Modules 552–561) 6 clues · The XOR (EOR) gate, OR versus XOR: the row where both inputs are 1, Telling similar gate symbols apart, Identifying a gate from its truth table output and more
✎
Crossword: 10 Boolean Logic (Modules 562–580) 10 clues · Completing a truth table from an expression: three inputs, Logic circuit: gates, wires and junctions, Tracing one input combination through a circuit, Completing a truth table from a logic circuit and more
🔎
Word Search: 7a Program Development Life Cycle (Modules 1–26) 20 words to find · The program development life cycle, The analysis stage, Identifying the problem, Abstraction (7a) and more
🔎
Word Search: 7a Program Development Life Cycle (Modules 27–46) 20 words to find · CONSTANT declarations, Assignment with ← (7a), INPUT command, OUTPUT command and more
🔎
Word Search: 7a Program Development Life Cycle (Modules 47–70) 20 words to find · REPEAT ... UNTIL loop (7a), Choosing between FOR, WHILE and REPEAT, Counting in a loop (7a), Totalling in a loop (7a) and more
🔎
Word Search: 7a Program Development Life Cycle (Modules 71–92) 21 words to find · Normal test data, Abnormal test data, Extreme test data, Boundary test data and more
🔎
Word Search: 7b Decomposition and Sub-systems (Modules 94–118) 21 words to find · Sub-system, Sub-systems made of further sub-systems, Component parts of a problem: inputs, Component parts of a problem: processes and more
🔎
Word Search: 7b Decomposition and Sub-systems and 7c Pseudocode and Flowcharts (Modules 123–145) 20 words to find · The subroutine symbol in a flowchart, Turning a structure diagram into a main flowchart and sub-flowcharts, Cambridge pseudocode: keywords in capitals and indentation, Pseudocode assignment: ← and more
🔎
Word Search: 7c Pseudocode and Flowcharts (Modules 146–165) 20 words to find · Writing literals in pseudocode, DECLARE a variable (7c), CONSTANT, Assignment with ← (7c) and more
🔎
Word Search: 7c Pseudocode and Flowcharts (Modules 166–187) 20 words to find · OTHERWISE in a CASE statement (7c), Choosing between CASE and IF, FOR ... TO ... NEXT, FOR loop with STEP (7c) and more
🔎
Word Search: 7c Pseudocode and Flowcharts (Modules 188–231) 21 words to find · Writing statements inside flowchart symbols, Flowchart for IF ... THEN ... ELSE, Flowchart for a WHILE loop, Flowchart for a REPEAT loop and more
🔎
Word Search: 7c Pseudocode and Flowcharts (Modules 232–253) 21 words to find · Explaining a flowchart, Finding errors in an algorithm, Error: = used instead of ←, Error: missing ENDIF, NEXT, ENDWHILE or UNTIL and more
🔎
Word Search: 7c Pseudocode and Flowcharts and 7d Standard Methods of Solution (Modules 254–274) 21 words to find · Reading a problem to plan an algorithm, Writing an algorithm in pseudocode from a problem, Writing an algorithm as a flowchart from a problem, Amending an algorithm and more
🔎
Word Search: 7d Standard Methods of Solution (Modules 275–295) 21 words to find · Reading and changing array elements, Looping through an array with FOR (7d), Standard methods of solution, Totalling: how it works and more
🔎
Word Search: 7d Standard Methods of Solution and 8.1a Data Types and Variables (Modules 296–316) 22 words to find · Outputting the result of a linear search, Tracing a linear search, Bubble sort: how it works, Swapping two values with a temporary variable and more
🔎
Word Search: 8.1a Data Types and Variables (Modules 317–336) 20 words to find · Assigning the result of an expression, Assigned value must match the variable's data type, Declaring a constant with CONSTANT, A constant's value must be a literal and more
🔎
Word Search: 8.1a Data Types and Variables and 8.1b Sequence, Selection and Iteration (Modules 337–357) 21 words to find · Power operator ^, Order of operations and brackets, DIV: integer division, MOD: remainder (8.1a) and more
🔎
Word Search: 8.1b Sequence, Selection and Iteration (Modules 358–378) 21 words to find · INPUT and OUTPUT statements, Indentation and comments in pseudocode, Writing a sequence in Cambridge pseudocode, Arithmetic operators including DIV and MOD and more
🔎
Word Search: 8.1b Sequence, Selection and Iteration and 8.1c Procedures and Functions (Modules 379–398) 21 words to find · Using the FOR counter inside the loop, WHILE…DO…ENDWHILE pre-condition loop, A WHILE loop ended by a rogue value, REPEAT…UNTIL post-condition loop and more
🔎
Word Search: 8.1c Procedures and Functions (Modules 399–418) 20 words to find · Parameter, Parameters and the values passed in a call, Difference between a procedure and a function, Pascal case names for subroutines and more
🔎
Word Search: 8.1c Procedures and Functions (Modules 419–438) 21 words to find · Common mistakes when calling procedures and functions, Choosing a procedure or a function for a task, Local variables, Global variables and more
🔎
Word Search: 8.1c Procedures and Functions and 8.2 Arrays (Modules 439–458) 20 words to find · Changing code in one place, Subroutines make programs easier to test and read, Explaining how subroutines make a program easier to maintain, Writing exam answers about procedures and functions and more
🔎
Word Search: 8.2 Arrays (Modules 459–478) 21 words to find · Looping with a lower bound of zero, Reading values into an array with INPUT in a loop, Displaying every element with OUTPUT in a loop, Totalling the elements of an array and more
🔎
Word Search: 8.2 Arrays and 8.3 File Handling (Modules 479–499) 21 words to find · Tracing nested loops over a 2D array, Choosing a 1D or 2D array for a scenario, Common array mistakes in pseudocode, Writing a complete array program: declare, fill and output and more
🔎
Word Search: 8.3 File Handling and 9 Databases (Modules 500–538) 20 words to find · Write, close, then read the data back, Copying a line of text from one file to another, Tracing a file handling program, Common mistakes in file handling pseudocode and more
🔎
Word Search: 9 Databases and 10 Boolean Logic (Modules 539–580) 20 words to find · Common mistakes in SQL scripts, What a logic gate is, Labelling inputs and the output: A, B, C and X, Truth table layout for two inputs and more

Journeys using these modules

IGCSE Computer Science 0478 — 7a Program Development Life Cycle, IGCSE Computer Science 0478 — 7b Decomposition and Sub-systems, IGCSE Computer Science 0478 — 7c Pseudocode and Flowcharts, IGCSE Computer Science 0478 — 7d Standard Methods of Solution, IGCSE Computer Science 0478 — 8.1a Data Types and Variables, IGCSE Computer Science 0478 — 8.1b Sequence, Selection and Iteration, IGCSE Computer Science 0478 — 8.1c Procedures and Functions, IGCSE Computer Science 0478 — 8.2 Arrays, IGCSE Computer Science 0478 — 8.3 File Handling, IGCSE Computer Science 0478 — 9 Databases, IGCSE Computer Science 0478 — 10 Boolean Logic, ACARA Digital Technologies Years 7–8 — Binary Number Representation, ACARA Digital Technologies Years 7–8 — Structured Data and Queries, ACARA Digital Technologies Years 7–8 — Tracing and Debugging Algorithms, ACARA Digital Technologies Years 9–10 — Acquiring and Validating Data, ACARA Digital Technologies Years 9–10 — Entities, Relationships and Queries, ACARA Digital Technologies Years 9–10 — Algorithms with Logical Operators, ACARA Digital Technologies Years 9–10 — Testing and Validating Programs, ACARA Digital Technologies Years 9–10 — Modular and Object-Oriented Programming (JavaScript), QCE Digital Solutions Unit 1 — Understanding Digital Problems, QCE Digital Solutions Unit 1 — Programmed Solutions, QCE Digital Solutions Unit 2 — Data-Driven Problems and Solution Requirements, QCE Digital Solutions Unit 2 — Data and Programming Techniques, QCE Digital Solutions Unit 2 — Prototype Data Solutions, QCE Digital Solutions Unit 4 — Complex Digital Data Exchange Problems and Solution Requirements, WA Computer Science ATAR Year 11 — Pseudocode and Algorithm Design, WA Computer Science ATAR Year 11 — Modular Programming, WA Computer Science ATAR Year 11 — Standard Algorithms, WA Computer Science ATAR Year 11 — Data Management

Or build your own Journey from any of these modules →

Frequently Asked Questions

Are these worksheets free?

Yes — every worksheet and its answer key is free to view, download, and print, with no account required to access any individual module.

Do I need an account?

No account is needed to view or print a worksheet. A free teacher account adds extras like assigning modules to a class and tracking progress automatically — it takes under three minutes to set up and doesn't need a credit card.

What year level is this for?

This curriculum is aligned to the Australian Curriculum (ACARA) and Victorian Curriculum, spanning roughly Years 3 to 10 — from first sequencing and variables through to object-oriented programming and advanced data structures. Start wherever matches your class's current level; each module builds on the last.

Can I print them?

Yes — every module has a one-click Print Worksheet button that generates a printable page with the practice questions and a full answer key.

Is this aligned to a curriculum?

Yes — the module sequence is mapped to the Australian Curriculum (ACARA) and Victorian Curriculum, and a class's progress is reported back against those curriculum bands (e.g. ACARA Years 5–6 sequencing and iteration, Years 7–8 functions and data structures), not just a generic difficulty scale.

Can students use this without a teacher?

Yes — students can start any module and practice directly, no class or account required. Joining a teacher's class with a class code adds progress tracking, class badges, and live Sprints, but isn't needed to work through the worksheets or modules solo.

Do I need to know IGCSE Computer Science Paper 2 myself to teach this?

No — every module comes with a full worked answer key, and Cloodit tracks who's stuck automatically, so you don't need to solve each exercise yourself before assigning it or be able to debug a student's work line by line.

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Pufferfish' badge — Error Handler, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

For Teachers

Set this curriculum for your class and see who needs help, automatically.

Create a free teacher account →

No credit card. No setup fee. Make a class and invite students in under three minutes.

For Students

Practice this topic interactively, track progress, and unlock badges.

Start Learning Free →

Have a class code?