Sunteți pe pagina 1din 9

FORM TP 2016175 MAY/JUNE 2017

CAR IBBEAN EXAM INATIO N S COUNCIL

CARIBBEAN ADVANCED PROFICIENCY EXAMINATION®

COMPUTER SCIENCE

FUNDAMENTALS OF COMPUTER SCIENCE

UNIT 1 – Paper 02

2 hours 30 minutes
SECTION A
COMPUTER ARCHITECTURE AND ORGANIZATION

Question 1.
(a) State the largest positive integer and the largest negative integer that can be stored using eight
bits with two's complement representation. [2 marks]

(b) Consider a floating-point representation that consists of a sign bit, three bits for the exponent,
and four bits to store the mantissa. Determine the decimal representation of the number 10111011.
[4 marks]

(c) Draw the truth table for the logic expression x . y' (i.e. x AND NOT y). [4 marks]

(d) Draw a circuit that can accept two binary inputs, referred to as x and y respectively. The
circuit should represent the propositional logic for x AND NOT y. [5 marks]

(e) Describe the function of the following circuits in a computer:

(i) Adder [1 mark]


(ii) Shift Register [1 mark ]
(iii) Counter [1 mark]

(f) Draw a clearly labelled diagram of a multiplexor that selects one output from four possible data
inputs. [4 marks]

(g) Describe how a multiplexor can be used to select the correct output in an ALU that contains
circuitry to execute the functions AND, OR, addition and shifting. [2 marks]

(h) State the number of selection control lines that are needed in a multiplexor that has 10 inputs.
[1 mark]
TOTAL 25 MARKS
Question 2.
(a) Draw a diagram that shows how a set of flip-flops can be used to create a 4-bit register. Note:
Each flip flop is able to store one bit of data. [4 marks]

(b) Describe the purpose of a decoder while accessing RAM. [2 marks]

(c) Derive the maximum number of RAM locations that can be accessed in a computer that uses
an 8-bit memory address. [2 marks]

(d) Explain why statements that access data stored in memory registers execute faster than
statements that access data stored in RAM. [3 marks]

(e) Name THREE phases of the instruction cycle and outline how each phase operates.
[6 marks]

(f) Discuss why a cache is expected to speed up a computer system. Include a definition of cache
in your explanation. [4 marks]

(g) ZERO RATED QUESTION. PUT NR FOR SCORE (DECISION BY CXC)


Explain why computers with a 32-bit word size are expected to operate faster than computers
with a 64-bit word size. [2 0 marks]
(Justification to settle your mind – During the editing process the word “whether” in the
question was changed to “why”, resulting in a question that does not make sense)-
Originally planned solution is below.

(h) State TWO examples of a use for information that is store in ROM. [2 marks]

TOTAL 25 MARKS
SECTION B
PROBLEM SOLVING WITH COMPUTERS
Question 3.

(a) Identify THREE properties of well-defined algorithms. [3 marks]

(b) Describe the problem analysis stage of the problem-solving process. [2 marks]

(c) The steps taken to convert a temperature from Fahrenheit to Celsius are as follows:

Step 1: Subtract 32 from the given temperature


Step 2: Multiply the result in Step 1 by 5
Step 3: Divide the result in Step 2 by 9

Write an algorithm that will:


- Prompt a user for a numeric value representing a temperature in Fahrenheit
- Convert the temperature to degrees Celsius
- Print the message “It‟s cold!” if the temperature in degrees Celsius is less than 17
[3 marks]
(d) Consider the algorithm below:
IF (num > 0)
IF (num == 2)
PRINT “FIRST”
ELSE
PRINT “SECOND”
ENDIF
ENDIF
PRINT “THIRD”

Draw the output of the algorithm when the value of num is


1. 0
2. 1
3. 2

[5 marks]
(e) A company is doing a poll on its employees “favourite” sport. If 50% or more of the employees
vote for any one activity then the company will have an event. Employees are asked to select one
of four choices: Cricket, Football, Cycling, None. If cricket, football or cycling is not an
employee‟s favourite sport then the employees must vote “None”.
Assuming that 3000 employees are polled and all votes are valid, write an algorithm that accepts
the vote of each employee and determines whether an event will be held or not. The algorithm
should print “Sport Event - YES” if the company will host the event and “Sport Event – NO” if
the company will not host the event. [12 marks]

TOTAL 25 MARKS
Question 4.

(a) List THREE types of control constructs. [3 marks]

(b) It is the end of the school year and Mr. Smith, a teacher, would like to purchase pizza for his
students. There are 12 slices in a large pizza and each student will be given one slice.
Write an algorithm which prompts the teacher for the number of students in the class, then prints
the number of large pizzas he would have to purchase and the number of slices that will remain
once each student is given one slice. [5 marks]

(c) Update the following algorithm so that it uses bounded iteration to find and print the sum of
the squares of ALL numbers between 0 and 1000, inclusive.

` WHILE (i != 1000) DO
sum = i * i
i = i + 1
ENDWHILE
PRINT i
[5 marks]

(d) A language course with 30 students has a written examination and an oral examination.
Students pass if they obtain a mark greater than 50.

Write an algorithm that will:


- Accept the mark for the written exam and the mark for the oral exam for every student
- Print how many students passed each exam
- Print the average score for all students in the written examination, and in the oral
examination [12 marks]

TOTAL 25 MARKS
PROGRAMMING
Question 5.

(a) Consider the function fact(n), defined as

int fact(int n)
{
int result = 1;
for (int i = n; i >= 1; i--)
{
result = result * i;
}
return result;
}
(i) State the values of i, n and result at the beginning of each iteration, if the function
fact(4) is invoked. [4 marks]

(ii) The function fact(n) can be represented as n!.


Write the function choose(int n, int r), which takes two arguments n and r and
returns an integer value equal to n!/((n-r)!r!). [3 marks]

(b) Explain how the assembly and linking process allow code written in high level
programming languages to run on a wide range of machines. [3 marks]
(c) The following data structure has been defined in C to support an environmental
monitoring application.

const int NUM_MONTHS= 12;


const int NUM_LOCATIONS = 20;
const int NAME_LENGTH = 20;

struct LocationHistory
{
char locationName[NAME_LENGTH];
int readings[NUM_MONTHS];
}
LocationHistory caribHistory[NUM_LOCATIONS];

A supporting module to the environmental monitoring application has populated the data
structure caribHistory with monthly average readings of the sea temperature of
different locations in the Caribbean (to the nearest degree Celsius) for one year. The data
population process indicates any erroneous reading by storing the flag value -1 in that
location.

(i) Write a C module numReadings(int islandIndex) that returns the


number of valid readings for a location specified by an index. [4 marks]

(d) (ii) Write a C module avgTemp(int islandIndex) that evaluates the average
temperature of a location for which the index is specified, ignores any erroneous readings
and returns the value as a floating point number. [5 marks]

(e) (iii) Write a main function that iterates over all records in the structure caribHistory
and prints a report with the location name, followed by the average if the data set for the
location is considered valid, otherwise a message saying the data set is invalid should be
printed. A data set is considered valid if less than half of the readings are erroneous. The
main function should use functions numReadings and avgtemp. Assume all location
names are terminated with the end of string character. [6 marks]

TOTAL 25 MARKS
Question 6.
(a) State TWO ways in which good programming style can be maintained and explain why
each is important. [4 marks]
(b) List THREE stages in the translation process. [3 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 location of the maximum value in the array. You
may assume all values are unique. [6 marks]

(d) A courier company operates in a certain country and charges a fixed fee for deliveries as
well as a variable fee based on the weight of each package; that is, $5 per pound. The company
operates in 4 zones and the associated fixed fees are as follows:
Each customer is assigned an ID that consists of a letter corresponding to the zone and a 5 digit
number. For example, S12557 refers to a customer from the South zone.
(i) Write a C function getZoneFee that accepts a customer’s ID and returns the flat fee to be
charged. [4 marks]
(d) (ii) Write a C function that accepts a customer’s ID and the weight of a package and returns
the delivery fee. Use your function from Part i above. [4 marks]

(e) Show the output generated by the following segment of code.

int n, c, k;
for (c = 1; c <= 5; c++)
{
for(k = 1; k <= c; k++)
printf("%d ", c);
printf("\n");
} [4 marks]
TOTAL 25 MARKS

S-ar putea să vă placă și