Cambridge IGCSE Computer Science 0478/22 May/June 2026 (Paper 2 Algorithms, Programming and Logic): Question-by-Question Guide
Cambridge IGCSE Computer Science 0478/22 is the May/June 2026 Paper 2 (Algorithms, Programming and Logic), variant 2. It lasts 1 hour 45 minutes, is worth 75 marks and is sat by every 0478 candidate. It had ten compulsory questions and no calculator, and the final question, a program to analyse a year of rainfall, carried 15 marks. This guide goes through the paper question by question and shows what the official mark scheme gave marks for. The paper and its mark scheme are free on the Tutopiya Learning Portal.
For an overview of both 0478 papers from this series, see IGCSE Computer Science 0478 May/June 2026 past papers: what came up and how it was marked.
0478/22 at a glance
| Question | Topic | Marks | Main command word |
|---|---|---|---|
| 1 | Pseudocode statements for iteration (multiple choice) | 1 | Tick |
| 2 | Data type for a single character (multiple choice) | 1 | Tick |
| 3 | Validation checks and a validation algorithm | 11 | Identify, explain, write |
| 4 | Coding and testing in the program development life cycle | 6 | Outline |
| 5 | A linear search on a 2D array: errors, name, “not found” message | 10 | Identify, state, write |
| 6 | Flowchart trace table and purpose | 7 | Complete, state |
| 7 | Files: why use them, reading a line from a text file | 5 | State, write |
| 8 | Logic circuit and truth table | 9 | Draw, complete |
| 9 | Database table, SQL query, a redundant field | 10 | Complete, describe |
| 10 | Rainfall statistics program | 15 | Write |
| Total | 75 |
Question-by-question walkthrough
Questions 1 and 2: multiple choice (2 marks)
- Question 1: the two iteration statements are FOR … NEXT and WHILE … DO … ENDWHILE (C). Every other option includes IF or CASE, which are selection.
- Question 2: a single letter, symbol or digit from the keyboard is a char (B).
Question 3: validation (11 marks)
-
Two named checks (2 marks): a check that data has not been left blank is a presence check; a value calculated from the other digits and placed at the end of a code is a check digit.
-
Format check (3 marks): its purpose is to check the input matches a required pattern or structure; it does this by checking for set numbers of letters and digits, or specific characters in set places; and an example, such as a date in dd/mm/yyyy form. An @ in an email address was allowed as the example.
-
Validation algorithm (6 marks): accept 15 whole numbers one at a time into the array Accepted[], making the user re-enter any number that isn’t whole, then say the check is complete. No declarations were needed. One mark each for:
- a loop that runs for 15 inputs
- inputting a number
- testing whether it is a whole number, for example with MOD, DIV or ROUND
- repeating the input until a whole number is entered
- storing the whole number in the right element of the array
- at least two messages, from the input prompt, an error message and the completion message.
The logic in outline: a count-controlled loop from 1 to 15; inside it, a post-condition loop that prompts, inputs, and checks whether the number has a remainder when divided by 1 (or doesn’t equal itself rounded to 0 places), showing an error if so; once the number passes, store it at the loop counter’s position; after the loop, output the completion message. Case was ignored.
Question 4: coding and testing (6 marks)
Up to three marks for each stage.
- Coding: writing the program in a programming language, using the designs (pseudocode, flowcharts, structure diagrams) from the earlier stage, adding comments so the code is maintainable, writing procedures and functions or using library routines, using a compiler, interpreter or IDE, and testing small parts as you go so each works as expected.
- Testing: testing the whole program at the end, using test data with known expected results, checking the program gives those results and accepts valid but rejects invalid data, and debugging the errors found. One mark at most was available for naming two types of test data, such as normal, abnormal, extreme and boundary.
Question 5: fixing a search on a 2D array (10 marks)
The algorithm was meant to look up a customer’s name from an account ID in a 1000-row array, where column 1 holds the ID and column 2 the name.
-
Four errors (4 marks):
- line 03 declares AccountID as an INTEGER, but IDs contain letters, so it should be a STRING
- line 05 uses OUTPUT where it should INPUT the ID
- line 07 uses CASE OF where it should be an IF statement (the ENDIF on line 10 gives this away)
- line 09 always outputs the first customer’s name, Accounts[1, 2], instead of Accounts[Row, 2].
-
Type of algorithm (1 mark): linear search. Sequential search was accepted.
-
A “not found” message (5 marks): you had to say where each new line goes, not rewrite the algorithm. The expected logic: set a Boolean flag to FALSE before the loop starts (before line 06); set it to TRUE where the ID is found (between lines 08 and 10); after the loop (after line 11), if the flag is still FALSE, output a message saying the account was not found. Any line number inside each range was accepted, and so was a clear description of the location. Without locations, the marks were capped: at most one mark for setting up the flag, one for changing it to TRUE and two for the final check and message.
The scheme also gave full credit to a version that replaces the FOR loop with a WHILE loop that runs while the flag is FALSE and the row is 1000 or less, with the row counter increased inside the loop. This stops searching once the ID is found.
Question 6: flowchart trace table (7 marks)
The flowchart inputs a word, then compares each letter with the next one and adds 1 to Count whenever they match. It stops comparing when NumLetter reaches the word’s length, outputs Count, and asks whether to go again.
- Trace table (6 marks, one per column): for post, WordLength is 4, NumLetter runs from 1 to 4, Count stays 0 and the output is 0. The user enters Y. For committee, WordLength is 9, Count rises to 1, 2 and 3 at the double m, t and e, and the output is 3. The user then enters N, so the algorithm stops. Bookkeeper is never input, so tracing it puts extra rows in the table. If no other marks were earned, one mark was available for correctly starting Count at 0 and NumLetter at 1, and the OUTPUT column could earn follow-through marks from your own final Count values.
- Purpose (1 mark): to count the number of pairs of repeated letters next to each other in a word.
Question 7: files (5 marks)
- Why store data in a file (1 mark): it is stored permanently, so it isn’t lost when the program or computer is switched off, it can be used again later or kept as a backup, or it can be moved to or shared with another computer.
- Read a line from Names.txt (4 marks): one mark each for declaring a suitably named variable, opening Names.txt for reading, reading the line into that variable, and closing the file. The file name and variable name must be the same throughout. Single or double quotes around the file name were fine; leaving the quotes off or using a different file name was penalised once only.
Question 8: logic circuit and truth table (9 marks)
The expression combined NOT, OR, NAND and XOR across three inputs, with a maximum of two inputs per gate and no simplifying.
- Logic circuit (5 marks): one mark for each correct gate with the correct inputs. Building it from the inside out: a NOT gate on C; an OR gate taking B and that inverted C; a NOT gate on the OR output; a NAND gate taking A and C; and an XOR gate combining the second NOT gate’s output with the NAND output to give Z.
- Truth table (4 marks): for inputs 000 to 111 in order, Z is 1, 0, 1, 1, 1, 1, 1, 0. Partial credit: 4 marks for all eight outputs, 3 for six or seven, 2 for four or five and 1 for two or three. A quick check: the left half is only 1 when B is 0 and C is 1, and the NAND is only 0 when A and C are both 1.
Question 9: a car parts database (10 marks)
- Data types (4 marks, one per two correct): PartID text; PartName text; CarType integer or text; Price real; Size text; Colour character; NumberInStock integer; InStock Boolean (text, character or integer were also accepted).
- SQL (4 marks): SELECT PartID, CarType, NumberInStock, FROM CAR_PARTS, WHERE PartName = “brake pads”. One mark for any two correct fields in the SELECT line, one for the third, one for the FROM line and one for the WHERE condition. The fields could be in any order, single quotes were fine, and close variants such as BrakePads or a minor misspelling of the value were allowed. Field names had to be spelt as in the table, and a space in a field or table name was penalised once.
- Why InStock is not needed (2 marks): NumberInStock already holds that information, because a value of 0 means the part is out of stock and anything above 0 means it is in stock.
Question 10: the rainfall program (15 marks)
The program had to set a 365-element array Rainfall[] to zero, input and store a rainfall figure in millimetres for each day, then calculate and output, with clear messages: the year’s total in centimetres to two decimal places, the mean daily rainfall in millimetres to four decimal places, the number of dry days, and the longest run of dry days in a row. If that run was 15 days or more, it had to output a drought message. The question required comments and declarations for every variable and array.
How it was marked. The scheme grouped the task into three requirements: declaring, initialising, inputting and storing the data; the four calculations (totalling, counting, rounding, selection and finding a maximum); and the outputs with the drought check. The answer was then placed in a band on two grids, best fit:
- AO2, up to 9 marks (bands 0, 1–3, 4–6, 7–9): the low band needs any use of a programming technique and some data stored; the middle band needs several techniques applied to this problem and some suitable data structures; the top band needs techniques that cover every requirement and data structures that store all the data.
- AO3, up to 6 marks (bands 0, 1–2, 3–4, 5–6): the low band is a program with few relevant comments, some sensible names and many inaccuracies that attempts at least one requirement; the middle band has some comments, mostly meaningful names and attempts most requirements, with some errors; the top band is fully commented, uses meaningful names throughout, is in a logical order and accurately performs every task. Minor syntax errors are ignored.
The logic in outline (one valid approach, not the mark scheme’s):
loop Day from 1 to 365: Rainfall[Day] ← 0
loop Day from 1 to 365: prompt, input Rainfall[Day]
Total ← 0, DryDays ← 0, CurrentRun ← 0, LongestRun ← 0
loop Day from 1 to 365:
add Rainfall[Day] to Total
if Rainfall[Day] = 0: add 1 to DryDays and to CurrentRun
if CurrentRun > LongestRun: LongestRun ← CurrentRun
otherwise: CurrentRun ← 0
output ROUND(Total / 10, 2) cm, ROUND(Total / 365, 4) mm, DryDays, LongestRun
if LongestRun >= 15: output a drought message
Two details decide marks: work out the mean from the total in millimetres before converting the total to centimetres, and reset the current run to zero on every day with rain. The longest run is the hardest part, and the top AO2 band needs every requirement covered, so attempt it even if you are unsure.
Where the marks are on 0478/22
| Skill | Questions | Marks |
|---|---|---|
| Writing a complete program | 10 | 15 |
| Writing, fixing and extending algorithms | 3(c), 5(a), 5(c), 7(b) | 19 |
| Written theory (validation, life cycle, files, search, databases) | 3(a), 3(b), 4, 5(b), 6(b), 7(a), 9(c) | 16 |
| Logic circuit and truth table | 8 | 9 |
| Database data types and SQL | 9(a), 9(b) | 8 |
| Trace table | 6(a) | 6 |
| Multiple choice | 1, 2 | 2 |
| Total | 75 |
- 34 marks came from writing code, counting Question 10 and the shorter algorithms. Writing pseudocode by hand under time pressure is the core skill this paper tests.
- The trace table, truth table, circuit and SQL are 23 marks with fixed answers and partial credit. These are the most reliable marks on the paper.
How to self-mark 0478/22 with the mark scheme
- Mark the short algorithms point by point. For 3(c), 5(c) and 7(b), tick each listed point your code contains. Your code doesn’t need to match the sample; any logic that does the job earns the point, and case is ignored.
- Check your locations in 5(c). If you didn’t say where the new lines go, apply the cap: one mark for the flag setup, one for setting it to TRUE and two for the final check.
- Mark the trace table by column. Each column is a mark. Use the follow-through rule for OUTPUT if your Count values went wrong earlier.
- Count your correct truth table rows and use the 4-3-2-1 scale. For the circuit, check each gate and its inputs separately.
- Mark Question 10 against the three requirements first. Tick what your program does under each, then pick the AO2 band from how much it covers and the AO3 band from your comments, names and accuracy. Be strict: missing rounding, a missing drought message or no declarations all count against you.
- Type and run your Question 10 program with a short test array, for example ten days, to check the longest dry run is right before you trust your band.
Sit 0478/22 as a timed mock
The paper allows 105 minutes for 75 marks. A workable plan that leaves Question 10 its full share:
| Block | Marks | Time |
|---|---|---|
| Questions 1–2 | 2 | 2 minutes |
| Question 3 | 11 | 13 minutes |
| Question 4 | 6 | 7 minutes |
| Question 5 | 10 | 13 minutes |
| Question 6 | 7 | 10 minutes |
| Question 7 | 5 | 6 minutes |
| Question 8 | 9 | 11 minutes |
| Question 9 | 10 | 11 minutes |
| Question 10 | 15 | 28 minutes |
| Check code and tables | – | 4 minutes |
| Total | 75 | 105 minutes |
Before you start Question 10, list the requirements as a checklist in the margin and tick each one off as you write it.
Other May/June 2026 0478 papers
Practise and download
- Download 0478/22 and its mark scheme on the Learning Portal →
- All 0478 May/June 2026 papers: overview and marking patterns
- Try a free IGCSE Computer Science quiz
Need help with a 0478 topic? Book a free trial lesson with an IGCSE Computer Science tutor →
Frequently asked questions
What topics were on 0478 Paper 22 May/June 2026? +
Ten questions: two multiple-choice items on iteration and data types; validation checks with a 6-mark validation algorithm; the coding and testing stages; fixing a linear search on a 2D array; a flowchart trace table; reading from a text file; a logic circuit and truth table; a car parts database with SQL; and a 15-mark rainfall statistics program.
How many marks is 0478/22 and how long is it? +
It is out of 75 marks and lasts 1 hour 45 minutes, with no calculator allowed. Question 10, the rainfall program, is the biggest at 15 marks.
How was the 15-mark program on 0478/22 2026 marked? +
Best fit against two level grids: up to 9 marks for AO2 (the programming techniques and data structures used) and up to 6 marks for AO3 (comments, meaningful names, logical order and how fully the program meets the requirements). Minor syntax errors are ignored, and pseudocode or a programming language are both accepted.
What were the four errors in Question 5 of 0478/22? +
Line 03 should declare AccountID as a STRING, line 05 should be INPUT rather than OUTPUT, line 07 should use IF rather than CASE OF, and line 09 should output Accounts[Row, 2] rather than Accounts[1, 2]. The algorithm is a linear search.
What did the trace table in 0478/22 Question 6 output? +
0 for post and 3 for committee. The user then enters N, so the algorithm stops and bookkeeper is never input. The flowchart counts pairs of matching letters next to each other in a word.
Where can I download 0478/22 May/June 2026 and its mark scheme? +
Both are free to download and print on the Tutopiya Learning Portal, on the Cambridge IGCSE Computer Science 0478 past papers page.
Ready to Excel in Your Studies?
Get personalised help from Tutopiya's expert tutors. Whether it's IGCSE, IB, A-Levels, or any other curriculum — we match you with the perfect tutor and your first session is free.
Book Your Free TrialWritten by
Mahira Kitchil
Connect on LinkedIn →Project Head, Tutopiya
Mahira Kitchil is a Project Head at Tutopiya, where she works with Cambridge IGCSE and Edexcel A-Level teachers in more than 20 countries on how exams are set and marked. She writes practical guides that help students find the right past papers and use the mark scheme the way examiners do, so every practice paper counts.
Related Articles
9706 Paper 12 May/June 2026: Questions and Mark Scheme
A Level Accounting 9706/12 May/June 2026 answer key: the topic of all 30 multiple choice questions, with the working for every calculation and the traps.
9706 Paper 22 May/June 2026: Questions and Mark Scheme
Question-by-question guide to A Level Accounting 9706/22 May/June 2026: every final figure, the key workings, the own figure marks and how advise parts score.
9706 Paper 32 May/June 2026: Questions and Mark Scheme
Question-by-question guide to A Level Accounting 9706/32 May/June 2026: the club accounts, the IAS 7 cash flow statement and the partnership takeover.
