Programming – A Level Computer Science (old syllabus, to 2021) (9608)

10 questions

0 / 0Answer a question to start your score.
New quizSaved 0

Quick quiz: 10 random questions from this topic. Answer them all, then open the Summary.

Advertisement
1
9608/23/M/J/16 · Question 4May/June 2016Paper 237 marks
Loading question…
Question text

4
(a) Name two features of your chosen high-level programming language that support the
implementation of a modular design.
1 …
2 …
[2]
(b) (i)
The structure chart shows part of the design of a program for an online shopping system.
The user has already added a number of products to their virtual basket.
Draw on the chart, the symbol to show that the process of modifying the basket contents
may be iterated (repeated).
Modify Basket Contents
D
B
E
A
F
C
Input product
Change product
Remove
data
quantity
product
[1]
(ii)
Each arrow in the structure chart above represents a parameter.
The table below shows the three data items that the six parameters pass between
modules.
Tick (✓) to match each parameter to the correct data item.
Parameter
Data item
A
B
C
D
E
F
Product ID
Quantity
Flag Value – indicating
operation success or fail
[4]

2
9608/23/M/J/20 · Question 5May/June 2020Paper 2336 marks
Loading question…
Question text

5
A company hires out rowing boats on a lake. The company has 20 boats, numbered from 1 to 20.
For safety reasons, the boats have to be serviced (checked and any damage repaired) regularly.
The company is developing a program to help manage the servicing of the boats.
Every time a boat is serviced, details are added at the end of the text file, ServiceLog.txt, as a
single line of information. Each boat is serviced before it is hired out for the first time.
The format of each line is as follows:
<BoatNumber><Date>
BoatNumber and Date are as follows:
•
BoatNumber is a two-digit numeric string in the range "01" to "20"
•
Date is an 8-digit numeric string in the format YYYYMMDD
The programmer has defined the first module as follows:
Module
Description
•
Called with a string parameter representing the BoatNumber
•
GetLastService()
Searches through the file ServiceLog.txt
•
Returns the date of the last service in the form "YYYYMMDD"
(a) Write pseudocode for the module GetLastService().
Refer to the Appendix on page 19 for a list of built-in pseudocode functions and operators.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…

3
9608/21/M/J/20 · Question 5May/June 2020Paper 2112 marks
Loading question…
Question text

5
(a) A 1D array, Directory, of type STRING is used to store a list of school internal telephone
numbers. There are 1000 elements in the array. Each element stores a single data item. The
format of each data item is as follows:
<Number><Name>
Number is a four-digit numeric string.
Name is a variable-length string.
For example:
"1024Collins Robbie"
The following pseudocode is an initial attempt at defining a procedure SortContacts()
that will perform a bubble sort on Directory. The array is to be sorted in ascending order of
Name.
Fill in the gaps to complete the pseudocode.
Refer to the Appendix on page 21 for a list of built-in pseudocode functions and operators.
PROCEDURE SortContacts ()
DECLARE Temp : STRING
DECLARE FirstName, SecondName : STRING
DECLARE NoSwaps : …
DECLARE Boundary, J : INTEGER
…
Boundary
REPEAT
TRUE
NoSwaps
1 TO Boundary
FOR J
… (Directory[J], LENGTH(Directory[J]) – … )
FirstName
RIGHT(Directory[J + 1], LENGTH(Directory[J + 1]) – 4)
SecondName
IF FirstName …
THEN
Directory[J]
Temp
Directory …
Directory[J]
Temp
Directory[J + 1]
…
NoSwaps
ENDIF
ENDFOR
…
Boundary
UNTIL NoSwaps = TRUE
ENDPROCEDURE
[8]
(b) The pseudocode contains a mechanism designed to make this an efficient bubble sort.
Describe the mechanism and explain why it may be considered to be efficient.
…
…
…
…
…
…
…
…
…
… [4]

Advertisement
4
9608/22/M/J/19 · Question 1May/June 2019Paper 2217 marks
Loading question…
Question text

1
(a) Algorithms are used in computer programming.
(i)
Explain the term algorithm.
…
…
…
… [2]
(ii)
Algorithms usually consist of three different types of activity.
Complete the table below.
The third activity type is given.
Activity type
Pseudocode example
…
…
…
…
…
…
…
Output
…
[5]
(b) Program variables have values as follows:
Variable
Value
Married
03/04/1982
ID
"M1234"
MiddleInitial
'J'
Height
5.6
IsMarried
TRUE
Children
2
(i)
Evaluate each expression in the following table.
If an expression is invalid, write ERROR.
For the built-in functions list, refer to the Appendix on page 16.
Expression
Evaluates to
STRING_TO_NUM(RIGHT(ID, 3))
INT(Height * Children)
IsMarried AND Married < 31/12/1999
LENGTH(ID & NUM_TO_STRING(Height))
MID(ID, INT(Height) – Children, 2)
[5]
(ii)
Programming languages support different data types.
Give an appropriate data type for the following variables from part (b).
Variable
Data type
Married
ID
MiddleInitial
Height
IsMarried
[5]

5
9608/21/O/N/17 · Question 1Oct/Nov 2017Paper 2117 marks
Loading question…
Question text

1
(a) (i)
Procedural high-level languages usually support different data types.
Give an appropriate data type for each data value in the following table.
Data value
Data type
27
"27"
"27.3"
TRUE
27/3/2015
27.3
[6]
(ii)
State an appropriate data structure to store the individual test scores for a class of
students.
… [1]
(iii)
Describe how characters are represented using the ASCII character set.
…
…
…
… [2]
(b) Functions and procedures are subroutines.
Explain why you should use subroutines when designing a program solution.
…
…
…
… [2]
(c) The following pseudocode is an example of nested IF statements.
IF MyVar = 1
THEN
CALL Proc1()
ELSE
IF MyVar = 2
THEN
CALL Proc2()
ELSE
IF MyVar = 3
THEN
CALL Proc3()
ELSE
OUTPUT "Error"
ENDIF
ENDIF
ENDIF
Use pseudocode to write a CASE statement with the same functionality.
…
…
…
…
…
…
…
… [4]
(d) Program coding is a transferable skill.
You are given program code written in a high-level language that you have not studied.
State two different features of the code that you should be able to recognise.
1 …
…
2 …
…

6
9608/21/M/J/19 · Question 1May/June 2019Paper 2120 marks
Loading question…
Question text

1
(a) (i)
Algorithms may be expressed using four basic constructs. One construct is sequence.
Complete the following table for two other constructs.
Construct
Pseudocode example
…
…
…
…
…
…
…
…
…
…
[4]
(ii)
Simple algorithms usually consist of input, process and output.
Complete the table by placing ticks (‘3’) in the relevant boxes.
Pseudocode statement
Input
Process
Output
SensorValue * Factor
Temp
WRITEFILE "LogFile.txt", TextLine
WRITEFILE "LogFile.txt", MyName & MyIDNumber
READFILE "AddressBook.txt", NextLine
[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
(i)
Evaluate each expression in the following table.
If an expression is invalid, write ERROR.
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]
(ii)
Programming languages support different data types.
Give an appropriate data type for the following variables from part (b).
Variable
Data type
Title
Version
PackSize
WeightEach
Paperback
[5]
(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.
Explain how data are chosen in black-box testing.
…
… [2]

7
9608/21/O/N/21 · Question 1Oct/Nov 2021Paper 2113 marks
Loading question…
Question text

1
Part of the procedure InitVars() is shown:
PROCEDURE InitVars()
DECLARE Var1 : INTEGER
// daily rainfall
DECLARE Var2 : REAL
// the average wind speed
DECLARE Var3 : STRING
// the ID number of the weather station
ENDPROCEDURE
(a) Give a more meaningful identifier name for each of the following variables used by the
procedure.
Variable
New identifier name
Var1
Var2
Var3
[3]
(b) A function called ProcessVars() assigns values to variables as shown.
Variable
Value
HouseCount
12
Turnout2018
20.23
TidalRiskCategory
'C'
IsConservationArea
FALSE
StationLocationName
"Ocean Boulevard"
Some pseudocode expressions in the function are shown in the following table.
Complete the table by evaluating each expression and writing the answer in the Evaluates to
column.
If the expression is invalid, write “ERROR” in the Evaluates to column.
Refer to the Appendix on pages 18–19 for a list of built-in pseudocode functions and operators.
Pseudocode expression
Evaluates to
LENGTH(HouseCount) > 6
MOD(INT(Turnout2018) * 3, 4)
ASC(TidalRiskCategory) + Turnout2018
IsConservationArea AND (HouseCount <= 50)
MID(StationLocationName, 1, 5) & " Eleven"
[5]
(c) The function header for ProcessVars() is:
FUNCTION ProcessVars(DataItem : REAL) RETURNS REAL
The following is an example of a parameter value passed to the function.
"L-MH-245,ManorHouse,N,F,230,12.34,0.98,12,N"
There is an error in the function header.
State the error and write the correct function header.
Error …
…
Correct function header …
…
[2]
(d) A programmer writes program code using an Integrated Development Environment (IDE).
Define the following three features of an IDE.
Breakpoints …
…
…
Report (watch) window …
…
…
Single stepping …
…
…
[3]

8
9608/21/O/N/20 · Question 5Oct/Nov 2020Paper 2120 marks
Loading question…
Question text

5
A message may contain several hashtags.
A hashtag is a string consisting of a hash character ‘#’, followed by one or more alphanumeric
characters.
A hashtag may be terminated by a space character, the start of the next hashtag, any other
non-alphanumeric character, or by the end of the message.
For example, the following message contains three hashtags:
"#Error27 is the result of #PoorPlanning by the #Designer"
The hashtags in the message are "#Error27", "#PoorPlanning" and "#Designer".
A program is being developed to process a message and extract each hashtag.
A global 1D array of strings, TagString, will store each hashtag in a single element.
Unused array elements will contain an empty string. The array will contain 10 000 elements.
A developer has started to define the modules as follows:
Module
Description
•
Called with two parameters:
•
a message string
•
an integer giving the number of the required hashtag.
For example, GetStart(Message, 3) would search
GetStart()
for the third hashtag in the string Message
•
Returns an integer value representing the start position
of the hashtag in the message string, or value −1 if that
hashtag does not exist
•
Called with two parameters:
•
a message string
•
an integer giving the hashtag start position within the
GetTag()
message
•
Returns the hashtag or an empty string if the character in
the message at the hashtag start position is not '#'
•
Called with a hashtag as a parameter
•
Returns the index position of the hashtag in array
GetIndex()
TagString
•
Returns the value −1 if the hashtag is not present in the
array
(a) Write pseudocode for the module GetIndex().
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…

Advertisement
9
9608/21/M/J/16 · Question 5May/June 2016Paper 2113 marks
Loading question…
Question text

5
Toni has a large collection of jazz CDs that are stored in different places. She wants to record
where the CDs are stored. She decides to write a program to do this.
The program must store the data in a file, MyMusic.
(a) (i)
Why is a file needed?
…
… [1]
MyMusic is a text file with the data for each CD as one line of text.
(ii)
Data for a typical CD are:
Title:
Kind of Green
Artist:
Miles Coltrane
Location:
Rack1-5
The line will be formed by concatenating the three data items.
For the example above, the line stored will be:
Kind of GreenMiles ColtraneRack1-5
Describe a problem that might occur when organising the data in this way.
…
…
…
…
Describe a possible solution.
…
…
…
…
[4]
(b) Toni must input the data into the file for all of her CDs.
A procedure, InputData, is needed to do this.
Toni designs the procedure and chooses the following identifiers:
Identifier
Data type
CDTitle
STRING
CDArtist
STRING
CDLocation
STRING
The procedure repeatedly performs the following steps:
•
input a CD title (A rogue value of “##” is to be used to end the input)
•
input the artist
•
input the location
•
create the text line
•
write the text line to the file
When the rogue value is encountered the file is closed.
Write program code for the procedure InputData.
Visual Basic and Pascal: You should include declaration statements for variables.
Python: You should show a comment statement for each variable used with its data type.
Programming language …
…
…
…
…
…
…
…
…

10
9608/23/O/N/18 · Question 5Oct/Nov 2018Paper 2310 marks
Loading question…
Question text

5
The function ReadFileLine() returns a specific line from a text file.
The function takes two parameters:
Identifier
Data type
Description
The name of the text file
FileName
STRING
The line number that is required
FileLine
INTEGER
The following pseudocode gives an example of the use of the function.
ReadFileLine(FileName, FileLine)
FileData
The function ReadFileLine() will:
•
open the file, FileName
•
read each line from the file until line FileLine is found or the end of the file is reached
•
if the line exists, return the string from this line; otherwise return the string "****"
Write pseudocode for the ReadFileLine() function.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…

Advertisement