Skip to content

Course home

Structured programming and subroutines (procedures and functions)

Structured programming and subroutines (procedures and functions)

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
Question 20

The following pseudocode shows a subroutine designed to calculate the total sum of all below-freezing temperatures (temperatures less than 0) recorded in an array of daily temperatures.

SUBROUTINE calculateFreezingTotal(temps)
  p ← 0
  j ← 0
  WHILE j < LENGTH(temps)
    IF temps[j] < 0 THEN
      p ← p + temps[j]
    ENDIF
    j ← j + 1
  ENDWHILE
  RETURN p
ENDSUBROUTINE

The identifier for the variable p in the subroutine is not a good choice.

State a better identifier for this variable that makes the algorithm easier to read and understand.

[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