CAMBRIDGE IGCSE COMPUTER SCIENCE
Winter 2025 · Paper 23 · Question 10 · 15 marks
← 0478 CS Hub Paper 23 · Winter 2025 0478 / Paper 2 Question 10 15 MARKS
15-mark question lab · start here

From two players’ random numbers to a crowned game winner.

Build the solution in a sensible order: validate both names, fill NumberGenerated with random numbers for each player, award the points round by round, store the totals, settle any tied game with fresh numbers, then report the results in descending order. Learn the reasoning before revealing the complete program.

2D arrayInput validationRANDOM generationPer-round pointsWHILE tie-break15 marks

Learning targets

By the end, you should be able to explain the algorithm before writing it.

Lesson overview

01 · Understand

Identify the two dimensions of NumberGenerated[,], the point rules for higher and equal numbers, and the tie-break condition that repeats until one fresh number is higher.

02 · Construct

Validate both names against empty entries, generate the numbers with RANDOM(1, 6) into the array, and award points inside a round loop with a nested IF/ELSE.

03 · Complete

Store the totals, repeat the tie-break until the fresh numbers differ, then output both names and totals in descending order with suitable messages.

!

How Cambridge awards the marks: the mark scheme gives AO2 a maximum of 9 marks and AO3 a maximum of 6 marks. It lists requirements R1–R5, but does not assign a separate fixed mark total to each R requirement. The stage-to-mark links in this guide show alignment, not invented stage marks.

Source question

Read the whole question first

Do not begin coding after the first paragraph. The empty-name rule, the exact point awards for higher and equal numbers, and the descending-order output all affect the structure of your solution.

Question 10 · 15 marks
Cambridge IGCSE Computer Science · 0478/23 · Question 10

A number game has two players. Random whole numbers are generated for each player. The numbers are compared and players are given points based on the result of the comparison.

The two-dimensional (2D) array NumberGenerated[] stores each number generated for each player. The first dimension stores the player number and the second dimension stores the random whole numbers generated.

The game is played as follows:

  • 100 random whole numbers between 1 and 6 inclusive are generated for player 1 and stored in the array.
  • 100 random whole numbers between 1 and 6 inclusive are generated for player 2 and stored in the array.
  • The first number generated for each player is compared and the player with the higher number is awarded 2 points. If the two numbers are the same, both players are awarded 1 point each.
  • The comparisons repeat for all 100 numbers generated.
  • The player with the higher total number of points is output as the winner.
  • If the players have the same total number of points, a new random whole number is generated for each player and compared. This is repeated until one player has a higher number than the other player. 2 points are added to that player’s total number of points, making this player the winner.

Write a program that meets the following requirements:

  • input and validate the names of the two players
  • generate 100 random whole numbers between 1 and 6 inclusive for each player and store them in the array NumberGenerated[]
  • calculate and store the total number of points for each player
  • output the name and total number of points for each player in descending order of total number of points.

You must use pseudocode or program code and add comments to explain how your code works.

You do not need to declare any arrays or variables; assume that this has already been done.
All outputs must contain suitable messages.

Before you move on

These are the five required techniques identified by the Cambridge mark scheme.

Mark-scheme map
R1

Input and validate the names of the two players, rejecting an empty entry until a real name is supplied.

R2

Generate 100 random whole numbers between 1 and 6 inclusive for each player and store them in NumberGenerated[].

R3

Compare the numbers round by round — 2 points for the higher number, 1 point to each player when equal — and calculate and store each player’s total.

R4

Output each player’s name and total number of points in descending order of total number of points.

R5

Settle a level game with fresh random numbers, repeating until one is higher, and add 2 points to that player.

Use the tabs along the top to work through the seven stages. The complete solution is kept in its own tab, and the interactive visualisation is the final tab.