0 ratings0% found this document useful (0 votes) 243 views9 pagesCAPE 2009 Computer Science Unit 1 Paper 2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
test cope 02115020
FORM TP 2009166 MAY/JUNE 2009
CARIBBEAN EXAMINATIONS COUNCIL
ADVANCED PROFICIENCY EXAMINATION
COMPUTER SCIENCE
UNIT 1 — FUNDAMENTALS OF COMPUTER SCIENCE
PAPER 02
24 hours
ee
15 MAY 2009 (a.m.)
INSTRUCTIONS TO CANDIDATES
1. Do NOT open this examination paper until instructed to do so.
2. Answer ALL questions from the THREE sections.
‘Copyright © 2008 Caribbean Examinations Couneil ©
All rights reserved.
02115020/CAPE 2009i)
(b)
©)
@
eae
SECTION A
COMPUTER ARCHITECTURE AND ORGANISATION
Answer BOTH questions.
Draw the symbol and give the corresponding truth table for THREE primary logic gates.
[6 marks]
The following is the truth table for an exclusive-OR gate:
Xesew
rong
zi
0
1
1
0
Using the primary logic gates from (a) above, design and draw a circuit which, behaves
exactly like an exclusive-OR gate. [6 marks}
Draw a clearly labelled block diagram of a4 x 1 multiplexer (4 inputs, 1 output)
[6 marks}
(@ — Caleulate the decimal equivalent of 00011011, [1 mark}
(ii) Determine if the result of 0111 + 1110 can be stored as a 4 bit binary number.
[2 marks]
(iii) Showing all working, find the largest and smallest integers that can be represented
using 4 bits signed magnitude.
Hint: the leftmost bit is to be used for the sign and the other bits are used for
representing the integer itself. [2 marks}
(iv) Find the 4 bit two’s complement of -5. [2 marks]
‘Total 25 marks
GO ON TO THE NEXT PAGE.
02115020/CAPE 2009ae
2, (a) _—_ Explain what is meant by EACH of the following terms:
(Word size
(ii) Cache memory
(iii) Clock speed
16 marks}
(b) Distinguish between EACH of the following pairs of terms as they pertain to computer
memory:
(@ ROM and RAM
(ii) Access speed and access method
(iii) Volatility and capacity [6 marks]
(© @__ Define the terms, ‘instruction set” and ‘instruction format’ [2 marks]
(ii) State THREE types of instructions that are typically included in an instruction set.
[3 marks]
(ii) Suppose 16 bits are used for representing instructions in a certain computer. Using
a diagram, explain how a 2-address instruction can be formatted using the 16 bits
~ available. [3 marks]
(iv) Describe what happens in a typical instruction cycle, assuming that direct addressing
02115020/CAPE 2009
is used, [5 marks]
Total 25 marks
GOON TO THE NEXT PAGESECTION B
PROBLEM SOLVING WITH COMPUTERS
Answer BOTH questions.
3. (a) What is an algorithm? [2 marks]
(b) Name THREE basic control constructs used in structured programming, [3 marks]
(©) The algorithm below is designed to generate, print and count the odd numbers between
(inclusive) to 99 (inclusive). However there are errors.
ai)
(iii)
02115020/CAPE 2009
while (j = 99)
print j
grpt2
e=et]
endwhile
print (°c =
print (j
end
+o)
‘What are the final values in the variables c and / when the algorithm terminates?
~ [2 marks}
By referring to the specific line numbers:
Identify and correct the errors in the algorithm. [6 marks]
Using the corrected algorithm, give the value of variable c at the end of execution.
[1 mark }
GO ON TO THE NEXT PAGE(4) Construct a flowchart to represent the following algorithm.
begin
read name
ifmame = ‘enddata’
print ‘no data supplied”
else
while name <> ‘enddata’
read amount
read quantity
sale = amount * quantity
print ‘This sale = ° , sale
read name
endwhile
endif
end
[11 marks}
Total 25 marks
GO ON TO THE NEXT PAGE
02115020/CAPE 20094. (a) __ BuyLo is a grocery. Management has decided that it needs to track all the goods that are
sold on a daily basis by using a computer-based solution.
Discuss what the ‘Identifying and evaluating possible solutions’ stage of problem solving,
would involve for BuyLo. [6 marks}
(6) 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:
+ printSpaces(n) prints n spaces from the current cursor position, use a dash ‘ ~* to
indicate a space
+ print continues output on the current line from the current cursor position
+ printin continues output on the current line from the current cursor position but any
subsequent output begins on a new line
SIZE = 10
begin
while j
begin
printSpaces( j +1) se (
print (**")
rintSpaces ( 8— j)
ne Aes Si
i
endwhile
zal Sud we GMS -
for j = 1 to (SIZE + 1) do A yait ie is coh. elo
print(‘*") OG ins i rib,
end for
printin ()
end
[11 marks]
(©) Write an algorithm that uses repetition to find the sum of all multiples of 7 between 14
(inclusive) and 126 (inclusive). [8 marks]
‘Total 25 marks
GO ON TO THE NEXT PAGE
02115020/CAPE 2009(a)
()
©)
SECTION C
PROGRAMMING
Answer BOTH questions.
Describe the “lexical analysis’ and ‘semantic analysis’ stages of the translation process.
[6 marks]
Write a C function which accepts two integer parameters, a and b, and retums the larger of
the two, Assume the integers are different, [4 marks]
Write a C program with the following functionality. The steps MUST be followed exactly
as stated.
Accept 10 integers from the user and place them in a text file *[Link]’, one integer per line.
Assume all integers are valid.
Close the file ‘[Link]’, reopen it, ead the data and find and print the average of the integers
stored in the file.
Print an appropriate message if the file cannot be found.
[Note: You cannot use arrays to solve this problem.]
[15 marks]
‘Total 25 marks
GO ON TO THE NEXT PAGE
02115020/CAPE 20096.
(a)
(b)
(c)
eg
Briefly describe EACH of the following classifications of programming languages:
@ Declarative
(ii) Imperative (procedural)
(iii) Scripting
[6 marks]
Distinguish between ‘syntax’ and ‘semantics’ as used in computer programming.
[3 marks]
You are given the following declarations in a C program:
struct payRec {
long int id;
float totalPay;
int numDays;
Be
Void main () // start of main function
{ int empld;
float pay, rate;
int hrs;
struct payRec Smith, Jones, Singh:
}
The declaration is used to create records to manipulate data on three employees Smith,
Jones and Singh, working for a small company. ‘id’ represent the identification number of
the employee, ‘totalPay” the amount of money he earns, ‘numDays’ the number of days
worked and ‘rate’ the hourly rate of pay. Assume that Smith’s id is 1000, Jones’ id is 1001
and Singh’s id is 1002 and all numDays fields are set to 0 initially.
Using the C program declaration, complete the main program by
= reading input data (explained later) and updating the totalPay and numDays fields
for each employee.
= prompting the user for id, hrs and rate, Calculate the salary by multiplying hrs by
rate for the employee and adding that result to the totalPay.
NOTE:
Anemployee can have more than one set of data, where each set corresponds to a
day worked by the employee.
Data are terminated by the sentinel id of 999.
At the end, print each employee id, total pay and number of days worked.
GO ON TO THE NEXT PAGE
02115020/CAPE 2009Sample screen:
Please enter ID: 1000
Enter hours worked: 10
Enter rate of pay: 10.50
Please enter ID: 1000
Enter hours worked: 3
Enter rate of pay: 10.50
Please enter ID: 1001
Enter hours worked: 5
Enter rate of pay: 5.50
Please enter ID: 1002
Enter hours worked: 10
Enter rate of pay: 10.50
Please enter ID: 999
NAME ID TOTALPAY —_ DAYS WORKED
Smith 1000 136.50 2
Jones 1001 27.50 1
Singh 1002 105.00 1
[16 marks}
Total 25 marks
END OF TEST
02115020/CAPE 2009