Skip to content

Course home

Sign up

Computational thinking

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
Question 98

A student is writing an algorithm for a warehouse stock allocation system. Shelf locations are tracked using arrays.

1  SET shelfA TO ["", "", "", "", "", "", "", "", "", ""]
2  SET countA TO 0
3  SET shelfB TO ["", "", "", "", "", "", "", "", "", ""]
4  SET countB TO 0
5  SET systemStatus TO "Active"
6  SET isFull TO False
7
8  DEFINE FUNCTION placeStock(pShelf, pBarcode)
9      DECLARE success AS BOOLEAN
10     SET success TO False
11     IF pShelf == 1 THEN
12         IF countA < 10 THEN
13             SET shelfA[countA] TO pBarcode
14             SET countA TO countA + 1
15             SET success TO True
16         END IF
17     ELSE
18         IF pShelf == 2 THEN
19             IF countB < 10 THEN
20                 SET shelfB[countB] TO pBarcode
21                 SET countB TO countB + 1
22                 SET success TO True
23             END IF
24         END IF
25     END IF
26     OUTPUT "Operation: " & success
27     RETURN success
28 END FUNCTION

Give a line number of an instruction in the algorithm that assigns a value to an element of an array.

[1]
Markscheme

Computational thinking Questions

  1. GCSE
  2. /Computer Science
  3. /Computational thinking

Question bank