Professional Documents
Culture Documents
PAPER 02
2½ hours
This examination paper consists of THREE sections: Computer Architecture and Organisation,
Problem Solving with Computers and Programming.
INSTRUCTIONS TO CANDIDATES
SECTION A
x y z
0 0 1
0 1 1
1 0 0
1 1 0
Using only primary logic gates, design and draw the circuit. [ 6 marks]
(b) Write down the truth table (i.e. list all possible input bit patterns and their corresponding
outputs) for the circuit in Figure 1.
p
q
Figure 1
[ 4 marks]
L )OLSÀRS [ 2 marks]
(d) (i) Draw a clearly labelled block diagram of a 2-to-4 line decoder. [ 3 marks]
(ii) A circuit is required for a television game show. The circuit must control four
light bulbs, B1, B2, B3, and B4. Only ONE of the light bulbs can be on at any
time.
State how a 2-to-4 line decoder can be used in the circuit and explain how the
bulbs are switched on. [ 3 marks]
I &RQVLGHUWKHIROORZLQJÀRDWLQJSRLQWUHSUHVHQWDWLRQ
1–bit sign, 3–bit exponent, 5– mantissa.
Calculate the decimal representation of 0 0 1 0 0 0 1 0 1 .
(Show all working.) [ 3 marks]
Total 25 marks
2. (a) Name and state the function of THREE registers found in the Central Processing Unit
(CPU). [ 6 marks]
(b) Compare main memory and TWO storage devices in terms of capacity and access speed.
[ 6 marks]
(c) Besides registers, name TWO other components in the CPU and state the function of
EACH. [ 4 marks]
G 'H¿QH WKH WHUP µFDFKH PHPRU\¶ DQG H[SODLQ KRZ LW LQFUHDVHV WKH HI¿FLHQF\ RI GDWD
retrieval. [ 4 marks]
Total 25 marks
SECTION B
3. (a) Describe any THREE stages in the problem solving process. [ 6 marks]
E 7KHDOJRULWKPEHORZ¿QGVWKHDYHUDJHDJHRIDVHWRIVWXGHQWV&RQVWUXFWDÀRZFKDUW
to represent the algorithm.
Algorithm
AverageAge
Sum = 0
Counter = 0
Read Age
While Age ! = 0
Sum = Sum + Age
Counter = Counter + 1
Read Age
End while
Average = Sum/Counter
Print Average
End
[11 marks]
(c) The algorithm below is designed to print a table of squares of all the even numbers
between 1 and 100 (inclusive). However, there are errors in the algorithm.
1. j=1
2. while j < 100
3. print “Even Number Square”
4. print “========== =====”
5. j * j = square
6. print j, square
7. end while
Total 25 marks
(b) 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. You should carefully
note the following:
print() continues output on the current line from the current cursor position.
println() continues output on the current line from the current cursor position
but any subsequent output begins on a new line
SIZE = 10
begin
i = SIZE - 1
while (i > 0) {
printSpaces (i)
print ("*")
y = (SIZE - i - 1) * 2
printSpaces (y)
println ("*")
i=i-1
}
println()
end
[11 marks]
(c) (i) Write an algorithm that uses iteration to print the sum of ALL multiples of 11
(integers) between 0 and 5 000, inclusive. [ 8 marks]
LL ,QGLFDWHZKHWKHUµERXQGHG¶RUµXQERXQGHG¶LWHUDWLRQZDVXVHGLQ\RXUUHVSRQVH
for 4 (c) (i) and state ONE reason for its use. [ 3 marks]
Total 25 marks
SECTION C
PROGRAMMING
5. (a) Apart from intermediate code generation, list TWO other stages of the translation
process. [ 2 marks]
(c) Write a C function which accepts an integer array and an integer variable indicating the
size of the array. The function should return the sum of all the numbers in the array that
are NOT greater than 100. [ 6 marks]
(d) A gym is having a contest. Members are asked to guess the number of jellybeans in
a jar. The winner is the member who accurately guesses the number of jellybeans or
whose guess is closest to this value without going over.
$OOWKHLQIRUPDWLRQUHODWHGWRWKHFRQWHVWLVVWRUHGLQD¿OHµFRQWHVWW[W¶7KH¿UVWOLQHRI
WKH¿OHJLYHVWKDWDFWXDOQXPEHURIMHOO\EHDQVLQWKHMDU(DFKOLQHWKHUHDIWHUFRQWDLQV
WKHJXHVVRIDPHPEHUIROORZHGE\KLVKHUPHPEHULGHQWL¿FDWLRQFRGHZKLFKLVDIRXU
digit integer). Data is terminated by – 1 (which appears on a line by itself).
:ULWHD&SURJUDPWKDWGHWHUPLQHVDQGRXWSXWVWRD¿OH³ZLQQHUW[W´WKHZLQQLQJJXHVV
DQGWKHZLQQHU¶VLGHQWL¿FDWLRQFRGH
You may assume all guesses are unique and a winner exists. You may not use arrays in
your solution. [15 marks]
Total 25 marks
E 'H¿QHWKHWHUPµGHEXJJLQJ¶ [ 2 marks]
(d) For any THREE integer values the following rules apply:
– The values cannot be the sides of a triangle if any value is 0 or negative and, if
any value is greater than the sum of the other two.
– The values can represent the sides of an equilateral triangle if all the values are
equal.
– The values can represent the sides of an isosceles triangle if two values are equal.
– The values can represent the sides of a scalene triangle if all the values are
different.
Write a C program that prompts the user for THREE integers and prints to the standard
output what triangle is represented. If no triangle is represented print “No triangle is
represented.” [11 marks]
(e) (i) In your answer booklet show the output generated by the following segment of
code.
int i, j;
(ii) Modify the code in e (i) so that the following output is generated.
1 2 3 4 5
2 3 4 5
3 4 5
4 5
5 [ 4 marks]
Total 25 marks
END OF TEST
02115010/CAPE 2011