You are on page 1of 8

THE BRITISH COMPUTER SOCIETY

THE BCS PROFESSIONAL EXAMINATIONS


BCS Level 4 Certificate in IT
SOFTWARE DEVELOPMENT
Tuesday 6th October 2009 - Afternoon
Time: TWO hours
Section A and Section B each carry 50% of the marks. You are advised to spend about 1 hour on Section
A (30 minutes per question) and 1 hour on Section B (12 minutes per question).

Answer the Section A questions you attempt in Answer Book A


Answer the Section B questions you attempt in Answer Book B
The marks given in brackets are indicative of the weight given to each part of the question.

Calculators are NOT allowed in this examination.


SECTION A
Answer TWO questions out of FOUR in Answer Book A. Each question carries 30 marks.

A1.

A practical magazine for amateur astronomers publishes data in a record structure, part
of which is shown below. Dates-visible is a pair of dates such that the named item is
visible from the first date to the second date.
Type = (planet, star, galaxy)
Planet
Name (10 characters)
Sun-distance (large real number)
Dates-visible
Magnitude (small integer)
Telescope-needed (Yes/No)
Star
Name (10 characters)
Constellation-name (10 characters)
Earth-distance (large real number)
Dates-visible
Magnitude (small integer)
Galaxy
Name (10 characters)
Earth-distance (large real number)
Dates-visible
Magnitude (small integer)
Telescope-needed (Yes/No)

Turn over]

A2.

a)

Write a declaration of this record data structure and any substructures that you
feel necessary in a language of your choice.
(10 marks)

b)

Design a program which has access to a file of these records and which requires
two pieces of input from its user, a type choice (1=planet, 2=star, 3=galaxy) and
a name. The output from the program is a printout of the information held for the
chosen item or a "not found" message if the item is not found in the file.
(20 marks)

The table below relates the musical key to numbered musical compositions by a
particular musician:
Key (+Sharps/-Flats)
4
3
2
1
0
-1
-2
-3
-4

Composition numbers
2, 19
11, 22
3, 14, 17
6, 9, 20, 23
1, 12, 15, 18, 26, 29, 32
4, 7, 21
10, 13, 24, 27
5, 16, 30
8, 25

a)

Show how to represent this table using either an array of linked lists or a two
dimensional array.
(6 marks)

b)

Which of these structures would be the best to use? Give your reasons.
(4 marks)

c)

Write a program to create the file compositions containing records each with a
key number and a composition number. The program is to request pairs of
numbers (key number and composition number) from the user with a suitable
method for the user to terminate input. [Note: error checking on the input is not
required].
(15 marks)

d)

Write a program to read from the file compositions and create the data structure
you defined in (a).
(5 marks)

A3.
program A
int mark(char* stuAns, tutAns){
int score;
if(stuAns == tutAns)
score = 0;
else
score = 1;
return(score);
}
int m = mark("Helo","hello");
a)

program B
FUNCTION mark(stuAns, tutAns AS STRING)
VAR score : INTEGER
IF stuAns EQUALS tutAns
score 0
ELSE
score 1
RETURN(score)
ENDFUNC
VAR m = mark("Helo","hello")

Choose either program A or program B and then find and copy out an example of
each of the following:

i) a reserved word
ii) a variable identifier
iii) an integer constant
iv) a type identifier
v) an assignment symbol
vi) a relational operator

vii) a punctuation symbol


viii) a formal parameter
ix) a local variable
x) a function identifier
xi) a string constant
xii) an actual parameter

(1 mark each, 12 total)


b)

Continuing with either program A or program B as in part (a), find and copy out
an example of each of the following:

i) a function call
ii) a function declaration
iii) an assignment statement

iv) a variable declaration


v) an expression with a boolean
(logical) value
vi) a conditional statement
(3 marks each, 18 total)

Turn over]

A4.

The array v has been initialised as follows


index 0
v
10

1
19

2
11

3
15

4
14

5
16

6
12

7
17

8
13

9
18

The function f in the code below is going to be executed with parameter p set to 2 and
parameter q set to 6. [You can choose to follow either version of the code]
a)

1
2
3
4
5
6
7
8
9
10
b)

Write down the sequence of values that are assigned to the variable y during the
function call and state the value that is returned from the call f(2,6)?
(8 marks)
Version A
int f(int p, q)
{
int x, y;
y = v[p];
for(x=p+1; x<=q; x++)
{
if( v[x]>y ) y=v[x];
}
return(y);
}

Version B
INTEGER FUNCTION f(p, q AS INTEGER);
BEGIN
INTEGER x, y;
y v[p];
FOR x FROM p+1 STEP 1 TO q DO
BEGIN
IF v[x]>y THEN y v[x]
END;
fy
ENDFUNC

Write a one sentence summary of what the function does.


(6 marks)

c)

Decide on better names for the identifiers (the function name, its parameters and
the variables) and rewrite the code [either version A or version B] using your new
names and including suitable comments.
(10 marks)

d)

A subprogram is independent if all the values it requires are provided inside it or


come via parameters. State, with reasons, whether the function f is independent
in this sense.
(6 marks)

SECTION B
Answer FIVE questions out of EIGHT in Answer Book B. Each question carries 12 marks.
B5.

Write a program to accept from the keyboard a sequence of data for a car in the format
below and write this to a file called carmiles. You are to devise an appropriate
terminator for the data.
date (yyyymmdd format) money spent (decimal currency) miles driven (real)
for example
20080923 40.98 456.7
20081012 21.42 123.4
(12 marks)

B6.

Data for the chemical isotopes of iron (Fe) is shown in the following table:
Atomic number
26
26
26
26

Symb
ol
Fe
Fe
Fe
Fe

Mass
number
54
56
57
58

Abundance Pi %

isomassi

5.90
91.52
2.25
0.33

53.95
55.9527
56.95359
57.952

The relative atomic mass Amass for a chemical element is calculated from its isotope
masses isomass using the formula below where N is the number of isotopes, each
having a percentage Pi
N
Amass = isomassi * Pi / 100
i=1

B7.

a)

Show how to store the information from the table to allow a program to carry out
the relative atomic mass (Amass) calculation described above. You should avoid
storing redundant data items. Your data structure should be capable of storing
data for isotopes of other atoms such as chlorine (Cl).
(3 marks)

b)

Assuming that the data from the table had been input into a program in the style
you described in (a), complete an algorithm or program to input an atomic
number of an element and calculate and print its relative atomic mass Amass.
(9 marks)

Write a program to discover how many numbers between 1 and 40 can be expressed as
the sum of 4 positive squares (e.g. 15 = 12 + 12 + 22 + 32).
(12 marks)

Turn over]

B8.

A linked list has been set up with one data item and one pointer only in each element of
the list.
a)

Draw a diagram of this linked list with a pointer to its head. Show the pointer
movements when a member of the list is deleted.
(3 marks)

b)

Write a program declaration of the data structure needed.


(2 marks)

c)

B9.

Write pseudocode for a procedure (or function) deleteitem, with appropriate


parameters, to search for a data item held in the variable rejectitem and delete
the element holding that data item from the linked list.
(7 marks)

Define the following terms:


a)
b)
c)
d)

algorithm
iteration
GUI
code generator
(4 x 3 marks = 12 marks)

B10.

Documentation is an important part of the process of software development. Write brief


notes on documentation to answer the following questions:
a)
b)
c)
d)
e)
f)

why is documentation important?


who is it for?
what does it consist of?
how is it produced?
when is it produced?
what are the problems with it?
(6 x 2 marks = 12 marks)

B11.

Choose either version of the program below and then find occurrences of the following 6
errors. For each error you should give the line number and an explanation of the error.
a)
b)
c)
d)
e)
f)

identifier not declared


type error - index not allowed
array index out of bounds
syntax error
variable required
type error - invalid type
line
1
2
3
4
5
6
7
8
9
10
11
12
13
14

Version in C
void main();
int i,j;
float v[10];
{
i=1;
j=i[2];
k=i+j;
if(i>1 i=i-1;
v[0]=i;
if(v[0])j=1;
for(i=0;i<=9;i++)
v[i+1]=i;
2=i;
}

Version in Pascal
program p;
var i,j:integer;
v:array[0..9]of real;
begin
i:=1;
j:=i[2];
k:=i+j;
if i>1 i:=i-1;
v[0]:=i;
if v[0] then j:=1;
for i:=0 step 1 to 9 do
v[i+1]:=i;
2:=i;
end.
(6 x 2 marks = 12 marks)

B12.

Write brief notes to compare and contrast the following pairs of terms.
a)
b)
c)
d)

compile time / run time


pre-check loop / post-check loop
specification / design
queue / stack
(4 x 3 marks = 12 marks)

Turn over]

** END OF PAPER **

You might also like