S 23 42
S 23 42
doc
Make sure that your name, centre number and candidate number will appear on every page of this
document. This document must contain your answers to each question.
(a) Write program code to declare the global string array Animals to store 10 items.
Copy and paste the program code into part 1(a) in the evidence document.
[3]
(b) The main program needs to store the following animals in the array:
horse
lion
rabbit
mouse
bird
deer
whale
elephant
kangaroo
tiger
Copy and paste the program code into part 1(b) in the evidence document.
[2]
(c) The following pseudocode procedure sorts the array into a descending alphabetical order
using only the first character in each animal name.
The function LENGTH(DataArray) returns the number of elements in the array DataArray.
PROCEDURE SortDescending()
ArrayLength LENGTH(Animals)
FOR X 0 TO ArrayLength - 1
Temp Animals[………………]
Animals[Y] Animals[Y + 1]
Animals[Y + 1] ………………
ENDIF
NEXT Y
NEXT X
ENDPROCEDURE
Copy and paste the program code into part 1(c) in the evidence document.
[6]
(d) (i) Write program code to amend the main program to:
Copy and paste the program code into part 1(d)(i) in the evidence document.
[3]
Copy and paste the screenshot into part 1(d)(ii) in the evidence document.
[1]