You are on page 1of 10

TEST CODE 02115020

FORM TP 2015165 MAY/JUNE 2015

CARIBBEAN E XAM I NAT I O N S COUNCIL

CARIBBEAN ADVANCED PROFICIENCY EXAMINATION®

COMPUTER SCIENCE

FUNDAMENTALS OF COMPUTER SCIENCE

UNIT 1 – Paper 02

2 hours 30 minutes

15 MAY 2015 (a.m.)

READ THE FOLLOWING INSTRUCTIONS CAREFULLY.


5165

1. This paper consists of THREE sections.

2. EACH section consists of TWO questions.

3. Answer ALL questions in the THREE sections.

DO NOT TURN THIS PAGE UNTIL YOU ARE TOLD TO DO SO.


127112

Copyright © 2014 Caribbean Examinations Council


All rights reserved.

02115020/CAPE 2015
-2-

SECTION A

COMPUTER ARCHITECTURE AND ORGANIZATION

Answer BOTH questions.

1. (a) Your friend Samuel Carter would like you to design a security alarm system for his house.
The security alarm should sound if the alarm switch is enabled (turned on) and a window
or door is opened. For example, if the alarm switch is enabled and a window is opened,
the alarm should sound.

(i) Write down the truth table (that is, list all possible input bit patterns and their
corresponding outputs) for this scenario. [8 marks]

(ii) Using only primary logic gates, design and draw the associated circuit.
[4 marks]

(b) Explain what is meant by the term ‘demultiplexer’. [2 marks]

(c) Draw a clearly labelled block diagram of a 3-to-8 line decoder. [3 marks]

(d) Find the decimal equivalent of the hexadecimal number 1A53. Show ALL working.
[3 marks]

(e) Find the 8 bit two’s complement of –21. Show ALL working. [2 marks]

1-bit sign, 3-bit exponent, 5-bit mantissa

Calculate the decimal representation of 001101011. Show ALL working. [3 marks]

Total 25 marks

GO ON TO THE NEXT PAGE


02115020/CAPE 2015
-3-

2.
CPU. [6 marks]

(b) The following questions are related to the fetch-decode-execute

(i) State the purpose of the ‘fetch’ operation. [1 mark]

(ii) State the purpose of the ‘decode’ and ‘execute’ operations. [2 marks]

[1 mark]

(c) The following questions are related to memory.

(i) How does ROM differ from RAM? [4 marks]

(ii) Your friend is interested in purchasing a new computer. He is considering the

Advise your friend by explaining ONE advantage and ONE disadvantage of EACH
option. [4 marks]

(d) There are several registers found in the CPU.

(i) What is the collective purpose of these registers? [1 mark]

(ii) Name THREE registers found in the CPU and for EACH, describe its function.
[6 marks]

Total 25 marks

GO ON TO THE NEXT PAGE


02115020/CAPE 2015
-4-

SECTION B

PROBLEM SOLVING WITH COMPUTERS

Answer BOTH questions.

3. (a) Explain what happens during the ‘implementation and review’ phase of the problem-solving
process. [4 marks]

(b) Examine the following algorithms labelled Algorithm 1 and Algorithm 2 and answer the
questions that follow.

Algorithm 1

FOR Y = 1 TO 20 DO
PRINT Y
END FOR

Algorithm 2

READ Z
SUM1 = 0
WHILE Z > -1 DO
SUM1 = SUM1 + Z
READ Z
END WHILE

(i) Which of the algorithms above illustrates unbounded iteration? [1 mark]

(ii) Which of the algorithms above illustrates bounded iteration? [1 mark]

(iii) Explain how the loop in Algorithm 1 is expected to terminate. [2 marks]

(iv) Explain how the loop in Algorithm 2 is expected to terminate. [2 marks]

GO ON TO THE NEXT PAGE


02115020/CAPE 2015
-5-

(c) The following algorithm is designed to print a table of cubes of all the odd positive integers
between 7 (inclusive) and 121 (inclusive). However, there are errors in the algorithm.

1. print “Odd Number Cube”

2. print “========== =====”

3. j = 1

4. while j < 121

5. j * j * j = cube

6. print j, cube

7. j = j - 1

8. end while

so that it would achieve its objective. [8 marks]

of 11 between m (inclusive) and n (exclusive) where m and n are two positive integers
entered via the keyboard. Assume that n > m. [7 marks]

Total 25 marks

GO ON TO THE NEXT PAGE


02115020/CAPE 2015
-6-

4. (a) Trace through the execution of the following algorithm and draw the output in your answer
booklet exactly as it would be generated by the algorithm.

writeSym(n) prints n ‘$’ from the current cursor position.


writeSym(2) would print
$$

write(list-1) continues output of list-1 on the current line, from the current
cursor position.

writeln() terminates output on the current line. Subsequent output begins on a


new line

writeln(list-1) continues output of list-1 on the current line from the current
cursor position but any subsequent output begins on a new line.

SIZE = 12

j = SIZE – 4

while j >= 2 do

writeSym(j + 2)

writeln(‘#’)

j = j – 3

endwhile

writeln(‘*’)

for k = 1 to (j + 5) do

write(‘@’)

writeln()

[12 marks]

GO ON TO THE NEXT PAGE


02115020/CAPE 2015
-7-

start

print ‘Enter a:’

read a

Set total to 1

while a > –1 do

a = 2 * a;

if a < 20 then

a = a – 1

else a = a + 1

endif

total = total + a

print ‘Enter a:’

read a

endwhile

print total

stop

[13 marks]

Total 25 marks

GO ON TO THE NEXT PAGE


02115020/CAPE 2015
-8-

SECTION C

PROGRAMMING

Answer BOTH questions.

5. (a) The translation process comprises several stages.

(i) Describe the purpose of the lexical analysis stage of this translation process.
[3 marks]

(ii) Comment on the existence of error detection in this lexical analysis stage.
[1 mark]

(b) What is modular programming and how does it encourage good programming practices?
[2 marks]

student in his Biology class. This term, Mr James would like to automatically determine
the number of students gaining grades A, B, C and F, as well as the highest mark gained.
He has asked you to write a C program to do this.

the student mark.

1223B 50
2345A 89
4567X 76
4432K 65
5434C ...

testgrades.txt

testgrades.txt, and output


the number of students gaining the grades A, B, C and F and the highest mark gained. The

A = 80 to 100
B = 70 to 79
C = 60 to 69
F < = 59 [10 marks]

(d) A palindrome is a sequence of characters which give the same word when read in both
directions. For example, madam.

Write a C program which accepts a string from a user and determines whether the string
is a palindrome or not. Assume that all letters are lower case. [9 marks]

Total 25 marks
GO ON TO THE NEXT PAGE
02115020/CAPE 2015
-9-

6.

(i) Declarative [2 marks]

(ii) Imperative (procedural) [2 marks]

(iii) Scripting [2 marks]

(b) What output is produced by the following C program?

#include <stdio.h>

while (i <= j * 2) {

i = j - 3;

for (x = j; x >= 0; x = x - 2) {

printf(“x is %d j is %d i is %d\n”,x, j, i);

j--;

i++;

} //for

printf(“New i = %d”, i);

i = i + 3;

}//while

return 0;

}//main

[9 marks]

GO ON TO THE NEXT PAGE


02115020/CAPE 2015
- 10 -

(c) A vendor needs to use a C application to store data about some fruits that he sells. Each

quantity in stock (integer).

(i) Write a declaration for a C struct fruitRec that can store the record for a fruit.
[2 marks]

(ii) Declare TWO variables, apple and pear, that have the record structure declared
in (c) (i) above. [1 mark]

(iii) Write C code to put data into the apple struct of (c) (ii) above. You can use any
values you like. [2 marks]

(iv) Assume that two fruitRec structs, pine and mango, are already loaded with data.
Write C code to exchange the cost price and selling price values of pine and mango.
[2 marks]

(v) Assume that two fruitRec structs a, b are already loaded with data. Write C code

Quantity) – (Cost Price Quantity)


[3 marks]

Total 25 marks

END OF TEST

IF YOU FINISH BEFORE TIME IS CALLED, CHECK YOUR WORK ON THIS TEST.

02115020/CAPE 2015

You might also like