An algorithm is designed for an automated warehouse conveyor system to process incoming packages:
1 SET conveyorList TO ["Conveyor A", "Conveyor B", "Conveyor C", "Conveyor D"]
2 SET conveyorActive TO [True, False, True, True]
3 SET processedCount TO 0
4 SET status TO "Standby" # Global operational status
5 SET emergencyStop TO False
6
7 FUNCTION processItem(conveyorID, weight)
8 BEGIN
9 DECLARE status : BOOLEAN
10 SET status TO False
11 IF (conveyorActive[conveyorID] == True) THEN
12 SEND "Processing item on " & conveyorList[conveyorID] & " with weight " & weight TO LOG
13 SET processedCount TO processedCount + 1
14 SET status TO True
15 END IF
16 RETURN status
17 END FUNCTION
Compare the scope and memory use of the variable status referred to on line 4 of the algorithm, with the variable status referred to on line 10.
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.