Skip to content

Course home

Structured programming and subroutines (procedures and functions)

Structured programming and subroutines (procedures and functions)

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
Question 56

An astrophysicist is developing an algorithm to process radio telemetry data from a deep-space satellite. The telemetry is stored in a 2D array, where the first row contains the time of the reading and the second row contains the signal strength in decibels.

State what should be written in place of the labels L1 to L3 in the algorithm below to make it function correctly.

SUBROUTINE findPeakSignal(mode, totalReadings)
    telemetry ← [['01:00', '05:00', '09:00', '13:00', '17:00', '21:00'],
                 ['14', '98', '241', '12', '85', '3']]
    idx ← 0
    peakSignal ← -1
    IF mode = 'PEAK' THEN
        FOR j ← 0 TO totalReadings - 1
            strength ← STRING_TO_INT(telemetry[L1][j])
            IF strength > peakSignal THEN
                peakSignal ← strength
                idx ← L2
            ENDIF
        ENDFOR
    ELSE
        OUTPUT 'Alternative mode unavailable'
    ENDIF
    IF peakSignal ≠ -1 THEN
        OUTPUT 'Peak of ', telemetry[1][idx], ' reached at ', telemetry[0][idx]
    ENDIF
ENDSUBROUTINE

OUTPUT 'Enter operational mode (PEAK or BASE): '
selectedMode ← USERINPUT
findPeakSignal(L3, 6)

L1:

L2:

L3:

[3]
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