Sie sind auf Seite 1von 7
UNIVERSITY EXAMINATIONS UNIVERSITEITSEKSAMENS am UNISA lize. cos1512 Moyle 2017 RCO1512 SECOND PAPER INTRODUCTION TO PROGRAMMING I! uration 2Hours 75 Marks exauyers ad OR UA scHoeMAN SECOND Be SSH Closed book examination ‘This examination question paper remains the property of the University of South Africa and may not be removed from the examination venue (TURN OVER] UNIVERSITY EXAMINATIONS UNIVERSITEITSEKSAMENS UNISA len COS1512 May!June 2017 RCO1512 SECOND PAPER INTRODUCTION TO PROGRAMMING I Duraton 2 Hours 75. Marks EXAMINERS FIRST DR MA SCHOEMAN SECOND MS A THOMAS Closed book examination Thus examination question paper remains the property of the Unversity of South Africa and may not be removed from the examination venue ‘Thus paper consists of 6 pages and 6 questions Please make sure that you have all 6 pages with the 6 questions Instructions: ‘Answer all the questions Do all rough work in the answer book ‘The mark for each question is given in brackets next to the question Please answer the questions in the correct order If you want to do a question later, leave ‘enough space Number your answers and label your rough work clearly. * Marks are awarded for part of an answer, so do whatever you are able to in each question GOOD LUCK! [TURN OVER] 2 cosis12/ACO1512 7 May /June 2017 QUESTION 1 15] Find the errors in the following statements Explain the reason for each error, and provide the correct statements to achieve the desired effect char str[5] = "Stop", af (str '= "sTop") str = "STOP", QUESTION 2 (4] A recursive function is a function that calls itself unti a certain condition is met Write a recursive function CountDown that accepts an ant value as a starting value and displays a countdown to zero without using foops The starting value must be greater than 0, if this condition 1s true call the function by passing a value less than the previous value and if the condition is false the function should terminate E g when the call CountDown (3) 1s executed, the output should be orn QUESTION 3 7 31 The code fragment below either contains an error or a nsky statement. Identity and explain the error or nsky statement 1 float* a, 2 q = new float {3 456), 3 delete q, 4 ¥q = 4.67, a 32 The following code tragmenthas some errors Read the questions below and give the correct code for the hnes in error 1 ant * pl, ant * p2, ant x = 5, ant y = 10, ‘pl = x, *p2 = y, cout ce pl ce" * ee pa; pl = p2, cout << *pl + *p2 + 10, [TURN OVER]