Skip to content

Course home

Sign up

Subprograms

EasyMediumHard
12345678910111213141516
Question 3

An algorithm is designed for a greenhouse monitoring system to log environment sensor readings:

1  SET sensorList TO ["Temp", "Humid", "Light", "CO2"]
2  SET activeFlags TO [True, True, True, False]
3  SET logCount TO 0
4  SET mode TO "Standard"    # System operation mode
5  SET alertsEnabled TO True
6
7  FUNCTION recordReading(sensorNum, val)
8  BEGIN
9      DECLARE mode : BOOLEAN
10     SET mode TO False
11     IF (activeFlags[sensorNum] == True) THEN
12         SEND "Logging " & sensorList[sensorNum] & " value: " & val TO FILE
13         SET logCount TO logCount + 1
14         SET mode TO True
15     END IF
16     RETURN mode
17 END FUNCTION

Compare the scope and memory use of the variable mode referred to on line 4 of the algorithm, with the variable mode referred to on line 10.

[4]
Markscheme

Subprograms Questions

  1. GCSE
  2. /Computer Science
  3. /Subprograms

29 exam-style questions on Edexcel GCSE Computer Science Subprograms, covering Built-in and user-devised subprograms, Functions versus procedures, and Global and local variables. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank