Skip to content

Course home

Structured programming and subroutines (procedures and functions)

Structured programming and subroutines (procedures and functions)

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
Question 51

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

SUBROUTINE analyzeTemperatures(type, totalStations)
    readings ← [['Station A', 'Station B', 'Station C', 'Station D', 'Station E'],
                ['14.2', '-3.5', '22.1', '18.9', '-1.2']]
    idx ← 0
    maxTemp ← -100.0
    IF type = 'MAXIMUM' THEN
        FOR j ← 0 TO totalStations - 1
            temp ← STRING_TO_FLOAT(readings[L1][j])
            IF temp > maxTemp THEN
                maxTemp ← temp
                idx ← L2
            ENDIF
        ENDFOR
    ELSE
        OUTPUT 'Mode not supported'
    ENDIF
    IF maxTemp ≠ -100.0 THEN
        OUTPUT 'Highest temperature at ', readings[0][idx], ' is ', readings[1][idx], '°C'
    ENDIF
ENDSUBROUTINE

OUTPUT 'Enter MAXIMUM or MINIMUM: '
userMode ← USERINPUT
analyzeTemperatures(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