6Medium
0/6

A logistics warehouse manages the dispatch of items using two sorting bays. The pseudocode below is used to assign tracking numbers to the packages in these bays.

1
2 SET bay1 TO ["", "", "", "", "", ""]
3 SET index1 TO 0
4 SET bay2 TO ["", "", "", "", "", ""]
5 SET index2 TO 0
6 SET status TO "Normal"
7 SET loaded TO False
8
9 [MISSING FUNCTION HEADER]
10 BEGIN FUNCTION
11     BOOLEAN success
12     SET success TO False
13     IF (pBay = 1) THEN
14         IF (index1 < 6) THEN
15             SET bay1[index1] TO pPackage
16             SET index1 TO index1 + 1
17             SET success TO True
18         END IF
19     ELSE
20         IF (pBay = 2) THEN
21             IF (index2 < 6) THEN
22                 SET bay2[index2] TO pPackage
23                 SET index2 TO index2 + 1
24                 SET success TO True
25             END IF
26         END IF
27     END IF
28     SEND "success:" & success TO DISPLAY
29     RETURN (success)
30 END FUNCTION
31
32 SEND "Enter bay number and package ID:" TO DISPLAY
33 RECEIVE bayNumber FROM (INTEGER)KEYBOARD
34 RECEIVE packageID FROM (STRING)KEYBOARD
35 [MISSING FUNCTION CALL]
36

The algorithm is incomplete.

  • Line 9 should declare the function header (including name and formal parameters).
  • Line 35 should assign the result of calling the function to the existing global variable loaded, passing the correct arguments.

Construct the pseudocode for line 9 and line 35.

[6]

Subprograms Questions

Practise Edexcel GCSE Computer Science Subprograms with exam-style questions for GCSE Computer Science. 29 questions covering Built-in and user-devised subprograms, Functions versus procedures, and Global and local variables, matched to the Edexcel GCSE Computer Science (1CP2) specification and written in Paper 1 and Paper 2 style. Every question includes a full worked solution and mark scheme, so you can see where marks are awarded rather than just whether you got the answer right.

PreviousNext

Subprograms Questions

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