CSc9618 (As) - Mock 2 - Paper 2
CSc9618 (As) - Mock 2 - Paper 2
..................................................................................................................
..................................................................................................................
.........................
..................................................................................................................
..................................................................................................................
..................................................................................................................
..................................................................................................................
.........................
..................................................................................................................
..................................................................................................................
[4]
[4]
(b) Program variables have values as follows:
Variable Value
Title "101 tricks with spaghetti"
Version 'C'
Author "Eric Peapod"
PackSize 4
WeightEach 6.2
Paperback TRUE
For the built-in functions list, refer to the Appendix on page 16.
Expression Evaluates to
MID(Title, 5, 3) & RIGHT(Author, 3)
INT(WeightEach * PackSize)
PackSize >= 4 AND WeightEach < 6.2
LEFT(Author, ASC(Version) - 65)
RIGHT(Title, (LENGTH(Author) – 6))
[5]
Give an appropriate data type for the following variables from part (b).
(c) White-box and black-box are two types of testing. In white-box testing, data are chosen to
test every possible path through the program.
...................................................................................................................................................
Type ..........................................................................................................................................
Explanation ...............................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[2]
(b) Chris is asked to work on a program that has been coded in a language he is not familiar
with.
He has identified that the program contains the constructs: sequence, iteration and selection.
Identify three other features of the program that he should expect to recognise.
Feature 1 ..................................................................................................................................
Feature 2 ..................................................................................................................................
Feature 3 ..................................................................................................................................
[3]
(c) The following lines of code are taken from a program in a high-level language.
ON x {
15: Call ProcA
20: y := 0
25: y := 99
NONE: Call ProcError
}
Identify the type of control structure and describe the function of the code.
Description ................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[3]
3 (a) A student is developing an algorithm to search through a 1D array of 100 elements. Each
element of the array, Result, contains a REAL value.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
ScanArray() will modify the first two parameters so that the new values are
available to the calling program or module.
..........................................................................................................................................
..........................................................................................................................................
...........................................................................................................................................
For the built-in functions list, refer to the Appendix on page 16.
AfterSpace FALSE
NewString ""
RETURN NewString
ENDFUNCTION
(a) (i) Complete the trace table by performing a dry run of the function when it is called as
follows:
Result Clean("X∇∇∇Y∇and∇∇Z")
The symbol '∇' represents a space character. Use this symbol to represent a space
character in the trace table.
[6]
...........................................................................................................................................
..................................................................................................................................... [1]
(iii) The pseudocode is changed so that the variable AfterSpace is initialised to TRUE.
Result Clean("∇∇X∇∇∇Y∇and∇∇Z")
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [2]
• the array needs to be two dimensional, with 500 rows and 4 columns
• the elements of the array need to be initialised to the string "Empty"
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
(c) State the term used for changes that are made to a program in response to a specification
change.
1 ................................................................................................................................................
2 ................................................................................................................................................
3 ................................................................................................................................................
[3]
She is investigating how many times the random function needs to be called before every
number in a given series is generated.
• use the random number function to generate an integer value in the range 1 to 50
inclusive
• count how many times the random function needs to be called before all 50 values have
been generated
• output a message giving the number of times the random function was called.
For the built-in functions list, refer to the Appendix on page 16.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
6 A text file, MyCDs.txt, stores information relating to a Compact Disc (CD) collection. Information
about each CD is stored on three separate lines in the file as follows:
(a) A program, CDOrganiser, will be written to manage the stored information. The program will
consist of three modules: AddCD, FindCD and RemoveCD.
Give three reasons why it is good practice to construct the program using modules.
1 ................................................................................................................................................
2 ................................................................................................................................................
3 ................................................................................................................................................
[3]
(b) The module, FindCD(), will check whether a given CD exists in the collection. The module
will be implemented as a function.
• be called with two strings as parameters, representing the artist name and CD title
• return a string that gives the storage location, or an empty string if the given CD has not
been found.
Visual Basic and Pascal: You should include the declaration statements for variables.
Python: You should show a comment statement for each variable used with its data type.
Program code
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Each function returns an error if the function call is not properly formed.
Operators (pseudocode)
Operator Description
Concatenates (joins) two strings
&
Example: "Summer" & " " & "Pudding" produces "Summer Pudding"
Performs a logical AND on two Boolean values
AND
Example: TRUE AND FALSE produces FALSE
Performs a logical OR on two Boolean values
OR
Example: TRUE OR FALSE produces TRUE