CAPE Computer Science P2

You might also like

Download as pdf
Download as pdf
You are on page 1of 7
rest cope 02115020 FORM TP 2011163 C, MAY/SUNE 2011 CARIBBEAN EXAMINATIONS COUNCIL ADVANCED PROFICIENCY EXAMINATION COMPUTER SCIENCE UNIT 1: FUNDAMENTALS OF COMPUTER SCIENCE PAPER 02 24% hours 13 MAY 2011 (a.m. ‘This examination paper consists of THREE sectio Problem Solving with Computers and Programming. : Computer Architecture and Organisation, Each section consists of 2 questions ‘The maximum mark for each section is 50. ‘The maximum mark for this examination is 150, This examination consists of 7 printed pages. INSTRUCTIONS TO CANDIDATES 1, Do NOT open this examination paper until instructed to do so. 2. Answer ALL questions from the THREE sections. Copyright © 2009 Caribbean Examinations Council All rights reserved. 02115020/CAPE 2011 SECTION A COMPUTER ARCHITECTURE AND ORGANISATION Answer BOTH questions, (a) ‘The following is the truth table of a certain circuit: z 1 1 0 0 Using only primary logic gates, design and draw the circuit [6 marks] (b) Write down the truth table (ic. list all possible input bit patterns and their corresponding outputs) for the circuit in Figure 1. Pp q Do Figure 1 ft [4 marks] (©) Explain what is meant by the terms: (@) — Flip-flop ‘4 {2 marks] (i) Multiplexor _ [2marks] GO ON TO THE NEXT PAGE @ e) @ @ (b) © @ © (i) Drawa 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, BI, 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] Find the 4-bit two’s complement of -6. [2 marks} Consider the following floating point representation: 1-bit sign, 3-bit exponent, S— mantissa, Calculate the decimal representation of 001000101 (Show all working.) [3 marks} ‘Total 25 marks Name and state the function of THREE registers found in the Central Processing Unit (CPU). [6 marks] ‘Compare main memory and TWO storage devices in terms of capacity and access speed cae - [6 marks} Besides registers, name TWO other components in the CPU and state the function of EACH, [4 marks] Define the term ‘cache memory’ and explain how it increases the efficiency of data retrieval, [4 marks] (® State what is an ‘instruction format’ [1 mark } Gi) Name and describe TWO addressing modes. [4 marks] Total 25 marks GO ON TO THE NEXT PAGE -4- SECTION B PROBLEM SOLVING WITH COMPUTERS Answer BOTH questions, (a) Describe any THREE stages in the problem solving process. [6 marks} (b) The algorithm below finds the average age of a set of students. Construct a flowchart to represent the algorithm, Algorithm) AverageAge Sum =0 Counter = Read Age While Age !=0 ‘Sum = Sum + Age Counter = Counter + 1 Read Age End while avertige ='Sum/Counter Print Average End [11 marks} (©) The algorithm betow is designed to print a table of squares of all the even numbers between | and 100 (inclusive). However, there are errors in the algorithm. jel while j < 100 print “Even Number Square” NOV eepe end while print j, square By referring to the specific line number, identify and correct the errors in the algorithm so that it will achieve its obj [8 marks] Total 25 marks GO ON TO THE NEXT PAGE 4. (a)_ State THREE properties of a well-designed algorithm, [ 3marks} (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: + printSpaces(n} prints n spaces from the current cursor position; use a dash ‘~" to indicate a space in your answer booklet. + 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 i=SIZE-1 0) { printSpaces (i) print (***) y=(SIZE-i-1)*2 printSpaces (y) printin (*" isi-l ee - } for (i=: print (" 2*SIZE; i=i+1) ‘) printing) end [11 marks} (©) @_ Write an algorithm that uses iteration to print the sum of ALL multiples of 11 (integers) between 0 and 5 000, inclusive. [ Smarks] (i) Indicate whether ‘bounded’ or “unbounded” iteration was used in your response for 3 (c) (i) and state ONE reason for its use. [ 3marks] ‘Total 25 marks GO ON TO THE NEXT PAGE fa) (b) © @ Bigs SECTION C PROGRAMMING Answer BOTH questions. Apart from intermediate code generation, list TWO other stages of the translation process. [2 marks] Give TWO advantages of using a modular approach in programming. [2 marks] ‘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} A gymis 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. All the information related to the contest is stored in a file ‘contest.txt”. The first line of the file gives that actual number of jellybeans in the jar. Each line thereafter contains the guess of a member followed by his/her member identification code (which is a four digit integer). Data is terminated by — 1 (which appears on a line by itself) Write aC program that determines and outputs to a file, “winner txt”, the winning guess and the winner’s identification code. ‘You may assume all guesses are unique and a winner exists, You may not use arrays in your solution, [15 marks) ‘Total 25 marks GO ON TO THE NEXT PAGE @) (b) © @) @ Explain the term ‘white space’ [2 marks] Define the term ‘debugging’ [2 marks] Explain why programmers should practise proper indentation. [2 marks] 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 tiangle if all the values are ifferent. ‘Write @ 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.” [1 marks] (@ In your answer booklet show the output generated by the following segment of code. inti, js . 7

You might also like