CAMBRIDGE IGCSE COMPUTER SCIENCE
Summer 2026 · Paper 22 · Question 10 · 15 marks
← 0478 CS Hub Paper 22 · Summer 2026 0478 / Paper 2 Question 10 15 MARKS
15-mark question lab · start here

A year of rainfall, from 365 daily measurements to a drought verdict.

Build the solution in a sensible order: plan the declarations, zero the array, capture each day’s measurement, total the year and round both statistics, count the dry days and hunt the longest consecutive run, then report every result and decide whether there was a drought. Learn the reasoning before revealing the complete program.

DeclarationsArray initialisationROUND to 2 and 4 dpDry-run streak trackingDrought decision15 marks

Learning targets

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

Lesson overview

01 · Understand

Recognise what the question gives and what it demands: no pre-stored data, a declared Rainfall[] array for 365 days, four statistics at two rounding precisions, and an inclusive drought boundary.

02 · Construct

Build the program pass by pass: declare the array and variables, zero every element, input each day’s measurement, total and round, count the dry days, and scan neighbouring pairs for the longest dry run.

03 · Complete

Output every statistic with clear messages and use selection to deliver the drought verdict when the longest dry run reaches 15 days or more.

!

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. Nothing is pre-stored in this question — declarations, initialisation and input are all your job — and the two rounding precisions, the consecutive-run scan and the inclusive drought boundary each force a structural decision you should make on paper first.

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

A program is required to record and analyse the daily rainfall in millimetres for one year. Assume a year has 365 days.

The one-dimensional (1D) array Rainfall[] is used to store the daily rainfall measurements.

Write a program for the following requirements:

  • Initialise the array Rainfall[] to zero.
  • Input the rainfall measurement in millimetres for each day and store it in the array.
  • Calculate the following statistics after all the inputs have been made for the year:
    • the total rainfall for the year in centimetres (1 centimetre = 10 millimetres), rounded to two decimal places
    • the mean average daily rainfall in millimetres, rounded to four decimal places
    • the total number of days with no rainfall
    • the longest number of consecutive days in which there was no rainfall.
  • Output all the calculated statistics with clear and appropriate messaging.
  • If the longest number of consecutive days in which there was no rainfall is 15 or more, output a message to indicate there was a drought (a long period when there is little or no rainfall).

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

All arrays, variables or constants used must be declared for this algorithm.

All inputs and 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

Declare the array and variables, initialise Rainfall[] to zero, then input and store the rainfall in millimetres for each of the 365 days — declarations, initialisation, iteration, input.

R1

Input loop stores every daily measurement in Rainfall[] with a suitable prompt — iteration, input, output.

R2

Total the year’s rainfall, convert to centimetres and round to two decimal places; find the mean daily rainfall in millimetres rounded to four decimal places — totalling, rounding.

R2

Count the days with no rainfall and scan for the longest run of consecutive dry days — counting, selection, finding max.

R3

Output every statistic with clear messages and decide, with selection, whether the drought message (15 days or more) is needed — output, selection.

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.