Skip to content

Course home

Structured programming and subroutines (procedures and functions)

Structured programming and subroutines (procedures and functions)

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
Question 59

A weather station program uses an algorithm to find the location with the lowest recorded rainfall.

State what should be written in place of the labels L1, L2, and L3 in the algorithm below to successfully identify and output the station with the lowest rainfall.

SUBROUTINE findMinRainfall(searchType, numSensors)
    sensorData ← [['140', '35', '210', '12', '88'],
                  ['North-Peak', 'East-Valley', 'West-Coast', 'South-Ridge', 'Central-Plains']]
    idx ← 0
    minRain ← 9999
    IF searchType = 'MINIMUM' THEN
        FOR k ← 0 TO numSensors - 1
            rain ← STRING_TO_INT(sensorData[L1][k])
            IF rain < minRain THEN
                minRain ← rain
                idx ← L2
            ENDIF
        ENDFOR
    ELSE
        OUTPUT 'operation not supported'
    ENDIF
    IF minRain ≠ 9999 THEN
        OUTPUT 'Lowest rainfall at ', sensorData[1][idx], ' is ', sensorData[0][idx], 'mm'
    ENDIF
ENDSUBROUTINE

OUTPUT 'Enter command (MINIMUM or MAXIMUM): '
userQuery ← USERINPUT
findMinRainfall(L3, 5)
a.

L1

[1]
b.

L2

[1]
c.

L3

[1]
Markscheme

Structured programming and subroutines (procedures and functions) Questions

  1. GCSE
  2. /Computer Science
  3. /Structured programming and subroutines (procedures and functions)

131 exam-style questions on AQA GCSE Computer Science Structured programming and subroutines (procedures and functions). Each one has a worked solution and a mark scheme showing where the marks go.

Question bank