IGCSE Computer Science Paper 2 · Algorithms, Programming & Logic practice papers
75 marks · 1h 45m · includes scenario question. Each generated paper follows the 0478 Paper 2 · Algorithms, Programming & Logic format, with the same number and style of questions as the real exam, and comes with a Cambridge-style mark scheme.
Sample Paper 2 · Algorithms, Programming & Logic questions
Question 1Structured · 6 marks
(a)
Complete the truth table for the logic expression X = (NOT A XOR B) OR C
A
B
C
X
0
0
0
0
0
1
0
1
0
0
1
1
1
0
0
1
0
1
1
1
0
1
1
1
Table 1.1
[4]
(b)
State how many logic gates are needed to draw this circuit, and name them.
[2]
Show answers and mark scheme
Part
Answer and marking points
Marks
(a)
X column: 11010111
8 correct outputs B4 B3 for 6–7 correct, B2 for 4–5, B1 for 2–3
4
(b)
3: NOT, XOR, OR
3 gates B1 NOT, XOR and OR B1
2
Question 2Structured · 5 marks
A program accepts the number of tickets that can be bought in one order. The number must be a whole number from 1 to 6 inclusive.
(a)
Give one example of each type of test data for this input: normal, extreme and abnormal.
[3]
(b)
Give the two values of boundary data for the upper limit of this input.
[1]
(c)
Explain why the program should be tested with abnormal data.
[1]
Show answers and mark scheme
Part
Answer and marking points
Marks
(a)
normal: any whole number from 2 to 5; extreme: 1 or 6; abnormal: e.g. 11, −3, 2.5 or "two"
Normal: a whole number from 2 to 5 B1 Extreme: 1 or 6 B1 Abnormal: outside the range, not a whole number, or not a number B1
3
(b)
6 and 7
6 and 7 B1
1
(c)
to check that invalid data is rejected (by the validation)
To check that the program rejects invalid data / does not crash B1
1
Question 3Structured · 7 marks
A shop stores data in a database table called PRODUCTS.
ProductID
Name
Category
Price
Stock
P101
Puzzle
Toy
38.82
16
P102
Atlas
Book
12.60
19
P103
Chess
Game
35.39
60
P104
Robot
Toy
31.85
14
P105
Novel
Book
4.34
46
P106
Cards
Game
35.80
45
P107
Kite
Toy
20.28
50
Table 3.1
(a)
State the field that is the most suitable primary key.
[1]
(b)
Write an SQL query to display the Name and Price of products in the category Game with a price greater than 33, in descending order of Price.
[4]
(c)
State the output of: SELECT Name FROM PRODUCTS WHERE Stock < 30;
[2]
Show answers and mark scheme
Part
Answer and marking points
Marks
(a)
ProductID
ProductID B1
1
(b)
SELECT Name, Price FROM PRODUCTS WHERE Category = 'Game' AND Price > 33 ORDER BY Price DESC;
SELECT Name, Price B1 FROM PRODUCTS B1 WHERE Category = 'Game' AND Price > 33 B1 ORDER BY Price DESC B1
4
(c)
Puzzle, Atlas, Robot
All correct names B2 B1 for one error/omission
2
Question 4Structured · 5 marks
A program uses a bubble sort to put the array Values[1:6] into ascending order. Before sorting, the array contains: 31 40 15 9 18 27
(a)
Write the contents of the array after the first pass of the bubble sort.
[2]
(b)
State the number of swaps made in the first pass.
[1]
(c)
Explain how the algorithm knows the array is sorted, so that it can stop early.
[2]
Show answers and mark scheme
Part
Answer and marking points
Marks
(a)
31 15 9 18 27 40
31 15 9 18 27 40 B2 B1 if only one adjacent pair of values is in the wrong order
2
(b)
4
4 B1
1
(c)
A flag records whether any swap was made in a pass; if a complete pass makes no swaps the array is sorted
Uses a flag / Boolean variable set when a swap happens B1 Stops when a whole pass completes with no swaps B1
2
Question 5Structured · 6 marks
(a)
Identify the most suitable validation check for a book’s ISBN, to detect errors when the number is typed in.
[1]
(b)
Identify the most suitable validation check for a date of birth, in the form DD/MM/YYYY.
[1]
(c)
Identify the most suitable validation check for a password, which must have at least 8 characters.
[1]
(d)
A program accepts whole numbers from 2 to 44 inclusive. Give one example of normal, extreme and abnormal test data.
[3]
Show answers and mark scheme
Part
Answer and marking points
Marks
(a)
check digit
check digit B1
1
(b)
format check
format check B1
1
(c)
length check
length check B1
1
(d)
normal: e.g. 23; extreme: 2 or 44; abnormal: e.g. 49 or "ten"
normal between 2 and 44 B1 extreme 2 or 44 B1 abnormal outside range or wrong type B1
3
Question 6Structured · 5 marks
A one-dimensional array Score[1:50] stores 50 values of data type INTEGER.
Write an algorithm in pseudocode to search the array for a score input by the user and output how many times the score appears in the array.
[5]
Show answers and mark scheme
Part
Answer and marking points
Marks
Input target; Count ← 0; FOR loop 1 to 50; IF element = target THEN Count ← Count + 1; output Count
INPUT target value B1 Count initialised to 0 B1 FOR loop from 1 to 50 B1 IF Score[Index] = target THEN Count ← Count + 1 B1 OUTPUT Count after the loop B1
Riyaz Shaikh has mentored IGCSE, IB and A Level students for 15+ years, one-on-one, online and in Mumbai. The hardest questions on this site are the ones he uses to find a student's weak points.
Original Cambridge-style practice questions written for mentorriyaz.in. These are not Cambridge past paper questions, and this site is not affiliated with or endorsed by Cambridge University Press & Assessment. Updated 2026-11-04. Paper generator · mentorriyaz.in