Vous êtes sur la page 1sur 30

Reinforcement: 05-10 Years' relevant CIE answers.

Section 2.3

Past Papers Answers:


May/June 2000
Oct/NOV 2000
May/June 2001
Oct/NOV 2001
May/June 2002
Oct/NOV 2002
4.
An examination centre holds data about the candidates at that centre.
The data held is
4 digit candidate number
candidate name
gender
date of birth
number of subjects entered.
(a)
If there are 200 candidates entered by the centre, calculate the expected size of the file.
Show your working and give your answer in suitable units.
[6]

7.

(a)

Size of array calculated


Location of array decided
according to data type/size
Locations reserved
Array named in look up table.
Size of array stored in table
Lower bound of array stored in table
Upper bound of array stored in table
Data type stored in table
Address of first element stored in table
(1 per Max 4)
(b)

Describe how an array is initialised in the memory of a computer.

Describe how an array may be searched serially to find a specific data item.

Index set to 0
Array(index) searched
if = Item then found
Else increment index and repeat

http://sites.google.com/site/computing9691/
Page 1 of 30

Zafar Ali Khan (0336 281 0241)

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

Until found or error report.


(1 per -, max 4)
May/June 2003
Oct/NOV 2003
5.
Details of students in a college are stored in a computer system. Among data items stored are
_ the student's name
_ the student's address
_ the student's date of birth
_ the mark obtained in the last mathematics examination
_ whether or not the student wants to go on a college trip
_ how much the student owes towards the cost of the trip.
(b)
State data types that are suitable for each of the other pieces of data.

Date/integer
Integer
Boolean/yes or no
Currency/floating pt/real/integer

(4)

May/June 2004
4.
(b) A stock file in a warehouse has the following fields in each record.
Name of item.
Date of last delivery.
Price of item.
Whether or not an order is outstanding.
Number of that item left in stock.
(ii)
Given that there are approximately 10000 different items in the warehouse,
estimate the size of the stock file. You should clearly show all the stages in the
calculation.

Oct/NOV 2004
May/June 2005
Oct/NOV 2005
May/June 2006
A small business has one shop. It specialises in taking portrait photographs for customers.
Details of customers are stored on paper.
It is decided to buy a stand-alone computer and use it to store customer records in a file.
7.
The following fields are to be stored.
Customer name (to allow customer to be addressed properly when contacted)
Customer telephone number (so that customer can be contacted when their order has
been completed)
http://sites.google.com/site/computing9691/
Page 2 of 30

Zafar Ali Khan (0336 281 0241)

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

Date of original commission (so that customers are not kept waiting too long)
Whether or not the order has been paid for.
(a)
State a suitable data type for each of the four fields.
- text/character/string
- text/character/string/alphanumeric
- date/Integer Boolean (b)
-

[4]

It is assumed that there will never be more than 1000 records.


Estimate the total size of the file needed for these records.

10-30
5-20
2,4,6,8
1
(Total = 18-59)
+ 10%
* 1000
Div 1024 (1000)
Answer (19-64) Kb
(1 per unbracketed line, max 4)

[4]

Oct/NOV 2006
May/June 2007
Oct/NOV 2007
May/June 2008
Oct/NOV 2008
May/June 2009
2.
A stock file in a company has records of all the different items held in stock. The records each
hold a number of fields:
the name of the item in stock
description of the item
cost
whether or not in stock
number in stock
(a)
(i)
State a suitable data type for each field.
- Name: Text/String/alpha/alphanumeric
- Description: Text/String/alpha/alphanumeric
- Cost: Currency/integer/real/float
- Whether: Boolean
- Number: Integer
- (1 for first three, 1 for last 2)
(ii)

Field Sizes:

[2]

If there are 1000 items in stock, estimate the size of the stock file. (Show how
you worked out your answer.)
10 50
50 250
48
1

http://sites.google.com/site/computing9691/
Page 3 of 30

Zafar Ali Khan (0336 281 0241)

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

14
66 313 bytes

Total

(1)

(1) for showing that the field sizes should be added up


Multiply Total by 1000 (1) = 66000 to 313000 bytes
Add extra (10%) for overheads (1) = 72600 to 344300 bytes
Convert to sensible unit (1024) (1) = 70.9Kb to 344.3Kb.
(5 possible mark points, max 4)
[4]
Oct/NOV 2009. P11
Oct/NOV 2009. P12
3.
A library stores details of members on the member file.
(d)
The member file contains up to 10,000 records. The estimated size of each record is 250
bytes.
-

Multiply 250 and 10000 - Add 10%


Signify that should divide by 1024...
Twice
Answer between 2.35 and 2.75
M bytes
(1 per -, max 5)
[5]
Oct/NOV 2009. P13
May/June 2010. P11
May/June 2010. P12
May/June 2010. P13
Oct/NOV 2010. P11
3.
(a)
A school information system stores data about each student in the school.
For each of the following data items, state the most suitable data type. Justify your choice.
(i)
Home telephone number
-

Text/alpha/string/alphanumeric (not character)


These are sets of characters, not numbers/no calculation involved with them
(second mark depends on the first)
(ii)

Number of subjects studied

Integer/byte
Must be whole number
(iii)

[2]

[2]

Whether or not the student is going on the school trip

Boolean (accept yes/no, true/false, 0/1)


Only two possible values (yes/no)
[2]
Oct/NOV 2010. P12
Oct/NOV 2010. P13
3.
(a)
A shop's stock control system stores data about the goods in the shop.
For each of the following data items, state the most suitable data type. Justify your choice.
(i)
Bar code number
[2]
-

Text/alpha/string/alphanumeric
These are sets of characters not numbers
(ii)

Price in dollars

http://sites.google.com/site/computing9691/
Page 4 of 30

Zafar Ali Khan (0336 281 0241)

[2]
[2]

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

Real/Currency
There will be a fractional part to the value
(iii)

Whether on order or not

[2]

Boolean
Only two possible values (yes/no)
(b)

[2]

[2]

Using the example of the shop stock control system, explain how fields, files and records
are related.

Files (all the data on the stock) comprise...


Records (all the data about a single item of stock) comprise...
Fields (individual pieces of data in a record e.g. Price)
(1 mark only for hierarchy given without context)

[3]

May/June 2011. P11


May/June 2011. P12
May/June 2011. P13
Oct/NOV 2011 P21
1
Ahmed is writing a program to record the data of members of the school football squad.
(f)
Ahmed needs to store more information about the players. He creates a record
structure that contains PlayerID (a whole number between 1 and 50), Sex (m or f),
PlayerName, Position (f, d or g), and DateOfBirth.
Complete the table.

[10]
(f)

http://sites.google.com/site/computing9691/
Page 5 of 30

Zafar Ali Khan (0336 281 0241)

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

1 mark per cell [10]


Oct/NOV 2011 P22
2
Ahmed is writing a program to record the data of members of the school football squad.
The input data will be validated. One input is the number of years a member has played for
the team. This will be 0, 1 or 2.
(e)
Ahmed thinks it will be a good idea to allow only five attempts at getting the input data
correct. If it is not a valid entry after five attempts, then a message 'Please check which
values are allowed' should be output.
Modify the flowchart to include this additional check.

[5]

(e)

(f)

1 mark for a counter variable


1 mark for correctly initialising counter
1 mark for incrementing counter
1 mark for correct condition for terminating
1 mark for correct output from decision
Ahmed needs to store more information about the players. He creates a record

http://sites.google.com/site/computing9691/
Page 6 of 30

Zafar Ali Khan (0336 281 0241)

[5]

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

structure that contains PlayerID (a whole number between 1 and 50), Sex (m or f),
PlayerName, NumberOfYears and DateOfBirth. Complete the table.
[10]
(f)

1 mark per cell [10]


(g)

(g)

(h)

The squad has 30 members. Ahmed stores the records in an array called Squad. To
calculate how many females there are he designs this pseudocode.
NoOfFemales 0
Index 1
WHILE Index < 30
IF Squad[Index].Sex = 'f'
THEN
NoOfFemales NoOfFemales + 1
ENDIF
Index Index + 1
ENDWHILE
This pseudocode will only consider the first 29 records in the array.
(i)
State the name of this type of error.
[1]
(ii)
State the line that needs changing.
[1]
(iii)
Rewrite the line to ensure that the pseudocode will consider all 30 records.
[1]
(i) -logic (error) [1]

Write this updated pseudocode using a FOR loop ensuring that it will check all records in
the array.
[3]

http://sites.google.com/site/computing9691/
Page 7 of 30

Zafar Ali Khan (0336 281 0241)

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

(h)

NoOfFemales 0
FOR Index 1 TO 30
IF Squad[Index].Sex = f
THEN
NoOfFemales NoOfFemales + 1
ENDIF
ENDFOR
1 mark for correct FOR loop
1 mark for correct content of IF statement and condition
1 mark for ENDFOR in correct position or equivalent structure

[3]

Oct/NOV 2011 P23


2

Ahmed is writing a program to record the data of members of the school football squad.
The input data will be validated. One input is the number of years a member has played for
the team. This will be 0, 1 or 2.
The flowchart for the validation of number of years is shown below.

(f)

Ahmed needs to store more information about the players. He creates a record
structure that contains PlayerID (a whole number between 1 and 50), Sex (m or f),
PlayerName, NumberOfYears and DateOfBirth. Complete the table.
[10]

(f)

http://sites.google.com/site/computing9691/
Page 8 of 30

Zafar Ali Khan (0336 281 0241)

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

1 mark per cell [10]


(g)

The squad has 30 members. Ahmed stores the records in an array called Squad. To
calculate how many females there are he designs this pseudocode.
NoOfFemales 0
Index 1
WHILE Index < 30
IF Squad[Index].Sex = 'f'
THEN
NoOfFemales NoOfFemales + 1
ENDIF
Index Index + 1
ENDWHILE
This pseudocode will only consider the first 29 records in the array.
(i)
State the name of this type of error.
[1]
(ii)
State the line that needs changing.
[1]
(iii)
Rewrite the line to ensure that the pseudocode will consider all 30 records.
[1]

(g)

(i) -logic (error)

http://sites.google.com/site/computing9691/
Page 9 of 30

Zafar Ali Khan (0336 281 0241)

[1]

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

(h)

Write this updated pseudocode using a FOR loop ensuring that it will check all records in
the array.
[3]
(h)
Gtotal 0
FOR Index 1 TO 45
IF Club[Index].Position = G
THEN
Gtotal Gtotal + 1
ENDIF
ENDFOR
1 mark for correct FOR loop
1 mark for correct content of IF statement and condition
1 mark for ENDFOR in correct position or equivalent structure
[3]
May/June 2012. P21/22
1
Anna wants to find out about her fellow students reading habits. It will be part of her
Literature coursework.
She will ask questions online, so starts by designing a screen layout. The first four
questions will ask for:
students first name
date of birth
type of book they prefer (printed, audio-book or e-book)
whether student reads novels (yes/no)
(c)
The responses from each student will be stored as a record consisting of the following
fields:
FirstName
DateOfBirth
BookType
ReadsNovels
Complete the following table. Only a single value should be given for the Field Size.

[8]
(c)

[8]
http://sites.google.com/site/computing9691/
Page 10 of 30

Zafar Ali Khan (0336 281 0241)

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

(f)
(f)

The records will be held in a serial file.


Give three statements from a high-level language that may be used for the file
handling and explain what each does.
[6]
(File handling statement 1 mark; explanation 1 mark) 3
e.g. Pascal
AssignFile(Channel, ExternalFileName); gives the FileName a
Channel ID through which access can be made
Reset(Channel); opens existing file
Write(Channel, Record); writes record to file
Read (Channel, Record); reads record from file
Seek (Channel, RecordAddress); goes directly to record at
specified address
CloseFile (Channel); closes file
e.g. VB 2005
Channel = New FileStream(ExternalFileName,FileMode.Open)
FileReader = New BinaryReader(Channel)
NewFile = New FileStream(ExternalFileName, FileMode.Create
FileWriter = New BinaryWriter (NewFile)
Record.Field = FileReader.ReadString()
Record.Field = FileReader.ReadDecimal()
Record.Field = FileReader.ReadInt32()
FileWriter.Write(Field)
Channel.Close()
FileReader.Close()
FileWriter.Close()
NewFile.Close()
e.g. C#
channel = new FileStream(externalFileName,FileMode.Open)
fileReader = new BinaryReader(channel)
newFile = new FileStream(externalFileName, fileMode.Create
fileWriter = new BinaryWriter (newFile)
record.Field = FileReader.ReadString()
record.Field = FileReader.ReadDecimal()
record.Field = FileReader.ReadInt32()
fileWriter.Write(field)
channel.Close()
fileReader.Close()
fileWriter.Close()
newFile.Close()
[6]

Philipe is trying different ways of designing the process of entering data into an array.
He declares a variable called ArraySize and sets it to 3.
He declares an array Number[ArraySize].
He then writes the following pseudocode.
Element 1
WHILE Element < ArraySize DO
INPUT Number[Element]
Element Element + 1
ENDWHILE

http://sites.google.com/site/computing9691/
Page 11 of 30

Zafar Ali Khan (0336 281 0241)

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

(d)

Philipe wants to increase the size of the array to 500. This is too large to check with a
trace table.
Describe how you would check that the logic of the pseudocode is correct for 500
iterations.
[3]
(d)
check starting condition
check state at iteration 499
check state at iteration 500
check state at iteration 501 [Max 3]
May/June 2012. P23
1

Anna wants to find out about her fellow students' sporting activities. It will be part of her
Sports Studies coursework.
She will ask questions online, so starts by designing a screen layout. The first four
questions will ask for:
student's first name
age (16,17,18 or 19)
favourite sport
whether student is a member of a sports club (yes/no)
(c)
Several of the students are visually impaired.
Describe the design issues that Anna should consider to ensure these students can
answer the questions online.
[2]
(c)
possibility of making fonts larger
incorporating sound
changing colours
[2]
(f)
The records will be held in a direct access file.
Give four statements from a high-level programming language that may be used for the
file handling and explain what each does.
[8]
(f)
(File handling statement 1 mark; explanation 1 mark) 4
e.g. Pascal
AssignFile(Channel, ExternalFileName); gives the FileName a
Channel ID through which access can be made
Reset(Channel); opens existing file
Write(Channel, Record); writes record to file
Read (Channel, Record); reads record from file
Seek (Channel, RecordAddress); goes directly to record at
specified address
CloseFile (Channel); closes file
e.g. VB 2005
Channel = New FileStream(ExternalFileName,FileMode.Open)
FileReader = New BinaryReader(Channel)
NewFile = New FileStream(ExternalFileName, FileMode.Create
FileWriter = New BinaryWriter (NewFile)
Record.Field = FileReader.ReadString()
Record.Field = FileReader.ReadDecimal()
Record.Field = FileReader.ReadInt32()
FileWriter.Write(Field)
Channel.Close()
FileReader.Close()
FileWriter.Close()
NewFile.Close()
e.g. C#

http://sites.google.com/site/computing9691/
Page 12 of 30

Zafar Ali Khan (0336 281 0241)

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

channel = new FileStream(externalFileName,FileMode.Open)


fileReader = new BinaryReader(channel)
newFile = new FileStream(externalFileName, fileMode.Create
fileWriter = new BinaryWriter (newFile)
record.Field = FileReader.ReadString()
record.Field = FileReader.ReadDecimal()
record.Field = FileReader.ReadInt32()
fileWriter.Write(field)
channel.Close()
fileReader.Close()
fileWriter.Close()
newFile.Close()
3

Liliane wants to write a program to play chess. She will represent the board of 8 x 8
squares, using the 2-dimensional array Board[8,8].
Each element of the array will need initialising to zero. Later, if a chess piece is on a
square, it will take a value of 1.
She starts by writing pseudocode for the initialisation of a 4 x 4 board. This is easier to
trace.
01
RowNo 1
02
WHILE RowNo < 4 DO
03
ColumnNo 1
04
WHILE ColumnNo < 4 DO
05
Board[RowNo,ColumnNo] 0
06
ColumnNo ColumnNo + 1
07
ENDWHILE
08
RowNo RowNo + 1
09
ENDWHILE
(d)
State the count-controlled loop that would be better for this initialisation.
(d)
FOR loop
(e)
(e)

[8]

[1]
[1]

On a full 8 x 8 board, state the relative positions of the squares Board[1,8] and
Board[8,1] .
[1]
at opposite corners
[1]

(f)

Liliane's next task is to indicate that there are pieces occupying the first two rows of th8 x
8 board.
Each square in rows 1 and 2 will be given the value 1.
Draw a flowchart that shows how to do this, using loop structures and the variable
names previously used (Board, RowNo, ColumnNo).
[5]

(f)

Marking guide:
2 FOR loops
nested
row loop values only 1 & 2
assigning value 1
correct exit

http://sites.google.com/site/computing9691/
Page 13 of 30

Zafar Ali Khan (0336 281 0241)

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

http://sites.google.com/site/computing9691/
Page 14 of 30

Zafar Ali Khan (0336 281 0241)

[5]

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

Oct/NOV 2012 P21


4
Super Bikes will store the data in files.
(a)
One file will store the following data:
bike ID
bike type
date bought
currently needs repair
Complete the following table. Use a single value for Field Size.
Field Name Data Type Field Size (in bytes)

[4]
4

(a)

Give a tick for each correct cell. Marks are half the number of ticks (round up)
(b)
(b)

(c)

(c)

[4]

Estimate the size, in kilobytes, of the file if it stores the details of 90 bikes. Show your
working.
[4]
(6 + 20 + 8 + 1)
* 90 / 1024
* 1.1 (or equivalent)
=approx 3.4 KB
1 mark per row above
[4]
Using a high-level programming language, define a bike record with identifier
HireBike and the fields listed in part (a).
Programming language used
Code
[5]
e.g. Pascal
TYPE HireBike = RECORD
BikeID: String[6];
BikeType: String[10];
DateBought: TDateTime;
NeedsRepair: Boolean;
END;

e.g. VB 2005
http://sites.google.com/site/computing9691/
Page 15 of 30

Zafar Ali Khan (0336 281 0241)

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

STRUCTURE HireBike
DIM BikeID AS String
DIM BikeType AS String
DIM DateBought AS Date
DIM NeedsRepair AS Boolean
END STRUCTURE

e.g. C#
struct hireBike
{
public string bikeID, bikeType;
public dateTime dateBought;
public bool needsRepair;
}

1 mark for correct record structure


1 mark for each field

http://sites.google.com/site/computing9691/
Page 16 of 30

Zafar Ali Khan (0336 281 0241)

[5]

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

Oct/NOV 2012 P22


3
Super Cars will store the data in files.
(a)
One file will store the following data:
car registration
make of car
date car bought
whether on hire or not
Complete the following table. Use a single value for Field Size.

[4]
3

(a)

[4]
(b)

Estimate the size, in kilobytes, of the file if it stores the details of 100 cars. Show your
working.
[4]

(b)

(6 + 20 + 8 + 1)
* 100 / 1024
* 1.1 (or equivalent/similar)
= 3.8 KB
1 mark per row above

(c)

(i)

(ii)

[4]

Using a high-level programming language, define a car record with


Identifier HireCar and the fields listed in part (a).
Programming language
Code
[5]
Car records are stored in a file SuperCars.
Write a procedure, AddCar(), to add a record to the end of the file. The record is
passed as the parameter. You should assume that the file is not already in use.
[5]

(c) (i) Pascal


http://sites.google.com/site/computing9691/
Page 17 of 30

Zafar Ali Khan (0336 281 0241)

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

TYPE HireCar = RECORD


CarReg : String[6];
Make : String[20];
DateBought : TDateTime;
OnHire : Boolean;
END;

VB 2005
STRUCTURE HireCar
DIM CarReg AS String
DIM Make AS String
DIM DateBought AS Date
DIM OnHire AS Boolean
END STRUCTURE

VB6
Type HireCar
CarReg As String
Make As String
DateBought As Date
OnHire As Boolean
End Type

Python
class HireCar :
def __init__(self, carReg, make, dateBought, onHire) :
self.CarReg = carReg
self.Make = make
self.DateBought = dateBought
self.OnHire = onHire

1 mark for correct record structure heading


1 mark for correct record structure ending
1 mark for 2 STRING fields
1 mark for Date field
1 mark for Boolean field
Check programming examples
Penalise once for a repeat mistake
[5]
(ii) Pascal
PROCEDURE AddCar(VAR CarRecord);
BEGIN
AssignFile(CarFile, 'SuperCars');
Reset(CarFile);
Seek(CarFile, FileSize(CarFile));
Write(CarFile, CarRecord);
CloseFile(CarFile);
END;

VB 2005
SUB AddCar(BYREF CarRecord AS HireCar)
CarFile = New FileStream('SuperCars', FileMode.Append)
Writer = New BinaryWriter(CarFile)
CarFile.Write(CarRecord)
CarFile.Close()
END SUB

Python
import pickle
def addCar(CarRecord) :
http://sites.google.com/site/computing9691/
Page 18 of 30

Zafar Ali Khan (0336 281 0241)

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

CarFile = open("SuperCars", "ab")


pickle.dump(CarRecord, CarFile)
CarFile.close()

Accept pseudocode
1 mark for correct procedure heading
1 mark for parameter in procedure heading
1 mark for opening file for writing/appending
1 mark for accessing end of file
1 mark for writing record
1 mark for closing file
Oct/NOV 2012 P23
2
Super Bikes owns a rectangular parking area with 30 rows; each row has 4 bike spaces.
Each bike is always parked in the same space.
The array BikeSpace[30,4] stores the bike registrations.
Soni uses a flowchart to help him design a module to populate the array with the bike
registrations.
Input is terminated using the rogue value BK000.

http://sites.google.com/site/computing9691/
Page 19 of 30

Zafar Ali Khan (0336 281 0241)

[5]

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

(c)

(i)

(ii)
(iii)
(c)

(i)
(ii)
(iii)

[7]
One of the modules uses the expression:
Area /(SpaceWidth * SpaceLength EmptySpaces)
State the value of the part of the expression inside the brackets when
SpaceWidth 7
SpaceLength 4
EmptySpaces 28
[1]
If this expression is used with the above values, there will be an error.
State the name of this type of error.
[1]
Explain how the programmer can stop this type of error occurring during
execution.
[2]
0 (zero)
[1]
Run-time error (Allow logic error, arithmetic error)
[1]
check the value of the bracket before the division takes place // write error
trapping code
if bracket = 0 arrange for a message to be output // exception code
[2]

http://sites.google.com/site/computing9691/
Page 20 of 30

Zafar Ali Khan (0336 281 0241)

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

Accept answers in code


4

Super Bikes will store the data in files.


(a)
One file will store the following data:
bike registration
purchase cost of bike
insurance rating (A, B or C only)
whether or not service is due
Complete the following table. Use a single value only for Field Size.

[4]
4

(a)

[4]
(b)

Estimate the size, in kilobytes, of the file if it stores the details of 1000 bikes. Show
your working.
[4]

(b)

(5 + 8 + 1 + 1)
* 1000 / 1024
* 1.1 (or equivalent)
= 16.1KB (f.t.)
[4]

(c)

(i)

(c)

Using a high-level programming language, define a bike record with identifier


HireBike and the fields listed in part (a).
Programming language
Code
[5]
(ii) Bike records are stored in a file SuperBikes.
Write the code to read every bike record, count the number of bikes where service
is due and output the result. You should assume that the file is not already in use.
[9]
(i) e.g. Pascal
TYPE HireBike = RECORD

http://sites.google.com/site/computing9691/
Page 21 of 30

Zafar Ali Khan (0336 281 0241)

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

BikeReg: String[5];
PurchaseCost: Currency;
InsuranceRating: Char;
ServiceDue: Boolean;
END;

e.g. VB 2005
STRUCTURE HireBike
DIM BikeReg AS String
DIM PurchaseCost AS Decimal
DIM InsuranceRating AS Char
DIM ServiceDue AS Boolean
END STRUCTURE

e.g. C#
struct
{
public
public
public
public

hireBike
string bikeReg;
decimal purchaseCost;
char insuranceRating;
bool serviceDue;

1 mark for correct record heading


1 mark for correct record structure ending
1 mark for first 2 fields
1 mark each for 3rd and 4th field
(ii) e.g. Pascal
ASSIGNFILE(FS, SuperBikes);
RESET(FS);
BikesForService := 0;
WHILE NOT EOF(FS) DO
BEGIN
Read(FS, HireBike);
IF HireBike.ServiceDue
THEN
BikesForService:=BikesForService+1;
END;
WRITELN(Number of bikes for service: ,
BikesForService);
CloseFile(FS);

e.g. VB 2005
FS = NEW FileStream(SuperBikes,
FileMode.open)
BR = NEW BinaryReader(FS)
BikesForService = 0
DO WHILE FS.Position < FS.Length
HireBike.ServiceDue =
BR.ReadBoolean()
IF HireBike.ServiceDue THEN
BikesForService = BikesForService + 1
LOOP
WRITELINE(Number of bikes for service: ,
BikesForService);
BR.Close()
FS.Close()

e.g. C#
fs = new Filestream(SuperBikes, FileMode.Open);
http://sites.google.com/site/computing9691/
Page 22 of 30

Zafar Ali Khan (0336 281 0241)

[5]

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

br = new BinaryReader(fs);
bikesForService = 0;
do
{
hireBike.ServiceDue =br.Readbool();
IF (hireBike.ServiceDue)
{
bikesForService:=bikesForService+1;
}
}
while (fs.Position < fs.Length);
Console.Writeline(Number of bikes
for service: ,bikesForService);
br.Close();
fs.Close;

1 mark for initialising total


1 mark for assigning file name
1 mark for opening file for reading
1 mark for repeat/while loop
1 mark for reading record
1 mark for testing service due field set to true
1 mark for incrementing total
1 mark for outputting total
1 mark for closing file

[9]

May/June 2013. P21/22


1

Meena wants to develop a program to keep a record of her coursework assignments.


She will want to enter, sort and print out data.
She decides to modularise the solution.
(b)

(i)
(ii)

(iii)
(b)

(i)
(ii)

Each record needs another field to uniquely identify that record.


State an appropriate identifier for this field and state a suitable data type for it.
[2]
In a programming language write the declaration for the record structure, giving it
the identifier Assignment.
Programming language
Declaration
[4]
State the number of bytes needed to store a value in the field IsMarked.
[1]
courseworkID/other comparable
integer/other sensible [2]
PASCAL
TYPE Assignment = RECORD
CourseworkID : String[6];
Subject : String[10];
Title : String[10];
DateSet : TDateTime;
HandInDate : TDateTime;
IsMarked : Boolean;

http://sites.google.com/site/computing9691/
Page 23 of 30

Zafar Ali Khan (0336 281 0241)

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

DateReturned : TDateTime;
Mark : Integer;
END;
VB.NET / VB2005
STRUCTURE Assignment
DIM CourseworkID AS String
DIM Subject AS String
DIM Title AS String
DIM DateSet AS Date
DIM HandInDate AS Date
DIM IsMarked AS Boolean
DIM DateReturned AS Date
DIM Mark AS Integer
END STRUCTURE
VB6
Type Assignment
CourseworkID AS String * 6
Subject AS String * 10
Title AS String * 10
DateSet AS Date
HandInDate AS Date
IsMarked AS Boolean
DateReturned AS Date
Mark AS Integer
End Type
Note: string lengths optional
PYTHON
class Assignment :
CourseworkID = "";
Subject = ""
Title = ""
DateSet = datetime.date(1,1,1)
HandInDate = datetime.date(1,1,1)
IsMarked = False
DateReturned = datetime.date(1,1,1)
Mark = 0
Marking guidelines:
1 mark for correct record header
1 mark for correct definition terminator
1 mark for all 3 dates declared correctly
DateSet
HandInDate
DateReturned
1 mark for the following fields defined correctly for language
Subject
Title
IsMarked
Mark
(iii) 1

http://sites.google.com/site/computing9691/
Page 24 of 30

Zafar Ali Khan (0336 281 0241)

[4]
[1]

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

(c)
(c)

Describe what the function EOF() does when used in a program.


uses/detect a marker written to the file
immediately after the last record
when processing a variable length file
records can be processed until the marker is reached
returns a Boolean value [Max 2]

(d)

Meena creates a sequential file, MyAssignments, of Assignment records.


Using pseudocode write the algorithm to search this file for the first Physics
assignment.
OPENFILE MyAssignments FOR OUTPUT

[2]

CLOSEFILE MyAssignments
[4]
(d)

Found _ FALSE
WHILE NOT EOF(MyAssignments) AND NOT FOUND DO
Read next Record
IF Assignment.Subject = Physics
THEN
Found _ TRUE
ENDIF
ENDWHILE;
Marking guidelines:
set record found to false
while NOT EOF and record found is false
read next record
check subject field to see if it is the wanted one
if it is, set record found to true [Max 4]

Meena needs to be aware of her average grade and declares a variable AvMark, which
she decides will be a global variable.
To make future computation more straightforward Meena retrieves her marks from the file and
stores them in an array, Marks. This array has 30 elements, and marks range from 0 to 100.
(d)
State a suitable value to initialise each element of the array. Justify your choice.
Initial value
Reason
[1]
(d)
a suitable number, e.g. 1 (not any value between 0 and 100 inclusive)
reason: this mark is a dummy/rogue value
[1]
(e)
(e)

Write program code that will declare and initialise the array.
Programming language
Code
PASCAL
VAR Marks : ARRAY[1..30] OF INTEGER;
i : INTEGER;
FOR i := 1 to 30 DO
BEGIN
Marks[i] := -1;

http://sites.google.com/site/computing9691/
Page 25 of 30

Zafar Ali Khan (0336 281 0241)

[4]

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

END;
VB.NET / VB2005
Dim Marks(30) AS Integer
DIM i AS Integer
For i = 1 to 30
Marks(i) = -1
NEXT i
VB6
DIM Marks(30) AS INTEGER
DIM i AS Integer
FOR i = 1 TO 30
Marks(i) = -1
NEXT i
PYTHON
Marks = []
for i in range(0, 30) :
Marks.append(-1)
Marking guidelines:
1 mark for correct array declaration
1 mark for correct FOR loop
1 mark for assigning the value given in (d) to each element
1 mark for LOOPEND / declaration end

[4]

(f)

Write program code that will calculate the average of all the marks and assign it to
AvMark.
Programming language
Code
[5]

(f)

PASCAL
VAR Marks : ARRAY[1..30] OF INTEGER;
AvMark : REAL;
Count, Total, i : INTEGER;
BEGIN
......
Total := 0;
Count := 0;
FOR i := 1 to 30 DO
BEGIN
IF Marks[i] > -1 THEN
BEGIN
Count := Count + 1;
Total := Total + Marks[i];
END;
END;
AvMark := Total/Count;
END.
VB.NET / VB2005
Dim Marks(30) AS Integer
......
Dim Count AS Integer
Dim Total AS Integer

http://sites.google.com/site/computing9691/
Page 26 of 30

Zafar Ali Khan (0336 281 0241)

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

Dim i AS Integer
Dim AvMark AS Double
Total = 0
Count = 0
For i = 1 To 30 Then
If Marks(i) > -1
Count = Count + 1
Total = Total + Marks(i)
End IF
Next i
AvMark = Total/Count
VB6
DIM Marks(30) AS INTEGER
......
DIM Count AS INTEGER
DIM Total AS INTEGER
DIM i AS INTEGER
DIM AvMark AS DOUBLE
Total = 0
Count = 0
FOR i = 1 TO 30
IF Marks(i) > -1 THEN
Count = Count + 1
Total = Total + Marks(i)
END IF
NEXT i
AvMark = Total/Count
PYTHON
Marks = []
......
Total = 0
Count = 0
AvMark = 0
for i in range(0, 30) :
if Marks[i] > -1 :
Count = Count + 1
Total = Total + Marks[i]
AvMark = Total/Count
Marking guidelines:
1 mark for initialisation of total and marks count
1 mark for fully functioning loop
1 mark for ignoring the elements with the initial value
1 mark for incrementing count correctly
1 mark for totalling and dividing and assigning the result to AvMark
May/June 2013. P23
1

Meena wants to develop a program to keep a record of her examination results.


She will want to enter, sort and print out data which is stored as a file of records.
Each record will contain at least the following data:
subject

http://sites.google.com/site/computing9691/
Page 27 of 30

Zafar Ali Khan (0336 281 0241)

[5]

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

examination title
level
date sat
mark
An example of an examination title is General Certificate of Education.
The DateSat field will contain only the month and year that the examination was taken.
For all subjects the mark is between 0 and 100 inclusive.
The level is 'O' or 'A'.
(a)
Complete the table. Use a single value for the size.

[6]
1

(a)

[6]
(b)
(b)

(c)

Estimate how many records could be held in the file if there are 5 KB available for the
file.
[4]
addition of their field sizes
add 10% (x)
multiply 5 by 1024
divide by their (x)
[4]
(i)
(ii)

Each record needs another field to uniquely identify that record.


State an appropriate identifier for this field and state a suitable data type for it.
[2]
In a programming language write the declaration for the record structure, giving it
the identifier Exam.
Programming language
Declaration
[4]

http://sites.google.com/site/computing9691/
Page 28 of 30

Zafar Ali Khan (0336 281 0241)

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

(c)

(d)
(d)

(e)
(e)

(i)

ExamID / comparable
integer/ other suitable
(ii) e.g. Pascal
Type Exam = RECORD
Subject : String [10] ;
Title: String [20] ;
Level: Char ;
DateSat ; String [8] ;
Mark ; Integer ;
END ;
e.g. VB 2005
STRUCTURE Exam
DIM Subject AS String
DIM Title AS String
DIM Level AS String
DIM DateSat AS Date
DIM Mark AS Integer
END STRUCTURE
- Correct record header
- Definition terminator
- Date declared correctly
- All other fields declared correctly

[2]

[4]

Meena decides to modularise the solution.


Describe two ways in which a procedural programming language is appropriate when
modularising a solution.
[4]
easier to follow logic of problem
can focus on one part at a time
produces reusable code
easier to maintain
can debug a small section at a time [Max 4]
Describe what the function EOF() does when used in a program.
uses/detects a marker written to the file
immediately after the last record
when processing a variable length file
records can be processed until the marker is reached
returns a Boolean value [Max 2]

[2]

Meena needs to be aware of her average mark and declares a variable with identifier
MyAvMark which she decides will be a global variable.
(c)
State a suitable value to initialise each element of the array.

[1]

(c)

Integer value outside range 0100/ null value

[1]

(d)

In a programming language, write code that will declare and initialise MyMarks.
Programming language
Code
e.g. VB 2005

(d)

http://sites.google.com/site/computing9691/
Page 29 of 30

Zafar Ali Khan (0336 281 0241)

[4]

Reinforcement: 05-10 Years' relevant CIE answers.


Section 2.3

DIM MyMarks(50) AS INTEGER


DIM Count AS INTEGER
FOR Count = 1 TO 50
MyMarks(Count) = -1
NEXT Count
C#
Int [ ] myMarks;
myMarks = new int[50];
for (int count =1; count<50; count++)
{
myMark [count] = -1;
}
array declaration
FOR loop
assigning each element their value from (c)
Loop ending
(e)

(e)

[4]

20 marks have been read into elements 1 to 20. In a programming language,


Write code that will print out the highest and lowest marks that have been entered.
Programming language
Code
[6]
e.g. VB 2005
Highest = 0
Lowest = 0
FOR Count = 1 TO 20
IF MyMarks (Count) > Highest THEN
Highest = MyMarks (Count)
END IF
IF MyMarks(Count) < Lowest THEN
Lowest =MyMarks(Count);
END IF
Console.WriteLine(Highest: , Highest)
Console.WriteLine(Lowest: ,Lowest)
FOR loop
Setting a low highest value
Setting a high lowest value
Comparing each element with both these
getting correct highest and lowest values
output of values
[6]

http://sites.google.com/site/computing9691/
Page 30 of 30

Zafar Ali Khan (0336 281 0241)