Skip to content

Course home

Sign up

Subprograms

EasyMediumHard
12345678910111213141516
Question 4

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