9816 - 02 - Status Basic - Program Design - 2024
9816 - 02 - Status Basic - Program Design - 2024
Paper | 2
FOR Index = 1 TO 10
OUTPUT((Index * 5) DIV 2)
NEXT Index
(a) Tick (✓) one box in each row to identify whether each programming construct has or has not been used
in this program.
Constructs Has been used Has not been used
Sequence
Selection
Iteration
[2]
(b) (i) Give the first three numbers that will be printed by this algorithm.
………………………………………………...………….…………………..…………....[1]
(ii) Line 2 of the program is changed to PRINT (Index + 8).
Give the first three numbers that will now be printed.
………………………………………………....……………………………..…………....[1]
(c) Draw a flowchart to represent this section of program code without changing the output.
…………………..……………...………………………..…………………….……….…….
…………………..……………...………….………………………………….……….…….
…………………..……………...………………………..…………………….……….…….
…………………..……………...………….………………………………….……….…….
…………………..……………...………………………..…………………….……….…….
…………………..……………...………….………………………………….……….…….
…………………..……………...………….………………………………….……….…….
…………………..……………...………………………..…………………….……….…….
………………………..……………...……………………...……………………….……….
……………………………..……………..………………………………..………………[6]
2. Explain why constants, variables and arrays are used in programming.
(a) (i) Constants ………...……………...……………………..…………………….……….…….
……………………………..……………..………………………………..………………[1]
(ii) Variable………...……………...……………..………..…………………….……….…….
……………………………..……………..………………………………..………………[1]
(iii) Array………...…………….....………………………..…………………….……….…….
……………………………..……………..………………………………..………………[1]
(b) Write the name of the computer term being describe below.
is the process of removing unnecessary detail from a problem so that the …………………….
important details can be focused on.
is breaking down a problem /task into smaller sub , more that can be solved on …………..……....[2]
their own.
count = 1
count <=4 No
?
Paper | 2
Yes
OUTPUT Count * 2
count = count + 1
End
4. The algorithms shown have both been written with the intention of printing out the even numbers from
2 to 10 inclusive.
Algorithm A Algorithm B
X = 2 X = 2
WHILE X<>10 DO REPEAT
X = X + 2 X = X + 2
OUTPUT X OUTPUT X
ENDWHILE UNTIL X > 10
…………………..……………...………………………..…………………….……….…….
………………………..……………...……………………...……………………….……….
……………………………..……………..………………………………..………………[2]
5. The following is a function design in pseudocode. Line numbers are given for reference only.
01 FUNCTION CountDigits(InString : STRING) RETURNS CHAR
02
03 DECLARE nc : CHAR
04 DECLARE c : INTEGER
05 DECLARE n : INTEGER
Paper | 2
06
07
08 C 0
09 N LENGTH(InString) // get number of characters for loop
10
11 WHILE N > 0 // repeat until no more characters left
12
13 nc LEFT(InString,1)
14 n n - 1
15 InString RIGHT(InString,n) // remove first character
16
17 IF (nc < '0') OR (nc > '9')
18 THEN
19 // do nothing
20 ELSE
21 c c + 1
22 ENDIF 23
24 ENDWHILE
25
26 RETURN c
27
28 ENDFUNCTION
(a) (i) This pseudocode includes features that make it easier to read and understand.
State two such features.
………………………..……………...……………….………...……………………….……….
……………………………..……………..…………………………………..………………[2]
(ii) State two additional features that should be used to make this pseudocode easier to read and understand.
………………………..……………...……………….………...……………………….……….
……………………………..……………..…………………………………..………………[2]
(b) There is a mistake in the pseudocode that would produce a data type mismatch error if a programmer were
to write similar program code.
(i) Describe this mistake and how it may be corrected.
…………………..……………...……..…………………..…………………….………..…….
…………………..……………...……………………………………………….………...…….
…………………..……………...……..…………………..…………………….………..…….
…………………..……………...……………………………………………….………...…….
…………………..……………...……..…………………..…………………….………..…….
…………………..……………...……………………………………………….………...…….
…………………..……………...……………………………………………….………...…….
………………………..……………...……………….………...……………………….……….
……………………………..……………..…………………………………..………………[4]
Paper | 2
…………………..……………...……………………………………………….………...…….
…………………..……………...……………………………………………….………...…….
………………………..……………...……………….………...……………………….……….
……………………………..……………..…………………………………..………………[5]
(c) Study the function CountDigits(). Identify the features of the function in the following table.
Feature Answer
The number of times the function LEFT() is called from within CountDigits()
resulting from the call:
Result CountDigits("AB27C4")