You are on page 1of 4
2920/03 STRUCTURED PROGRAMMING July 2018 ‘Time: 3 hours THE KENYA NATIONAL EXAMINATIONS COUNCIL. DIPLOMA IN INFORMATION COMMUNICATION TECHNOLOGY MODULET STRUCTURED PROGRAMMING INSTRUCTIONS TO CANDIDA’ This paper consists of EIGHT quest Answer any FIVE of the EIGHT questions in the answer boaklet provided, ‘Candidates should answer the questions in English. This paper consists of 4 printed pages. Candidates should check the question paper to ascertain that all the Pages are printed us indicated and that no questions are missing. ©2018 The Kena National Examinations Council ‘Turn over vo @ ) ) tb) te) @ (b) 29201103, uly 2018 Outline thres advantages of structured programming kanguages, (3 marks} Differentiate between dow Jevel and Aigh devel programming languages, (4 marks) ‘Table I shows a five-day schedule of trips for students in various departments. Use it to answer the questions that fallow, Day | Destination 1 Tsavo 2 Mara a EPZ 4 Cocacola Plant Other | Not applicable Table | (i) Draw a Mowchart to represent the logic of @ program that could accept the day number and output the destination. (6 marks) Gi) Using a switch statement, write’a C program to implement the program logic. (7 marks) Explain each of the following statements as used in © programming: (i) sentinel; (2 marks) (ii) break, < (2 marks) Explain two disadvantages of monokifve programming, (4 marks) Distinguish between source cadkéaiid object cose as used in programming, (4 marks) The area A ofa triangle is ined using the formula 4 = JS(S-ay(S-BY(S-<) where ab and care the dimet@lGas of wiongte and s¢= ++ Write a C-program that would prompt for the three dimensions of a triangle, computes the-area and display the results to the nearest 3 decimal places, (8 marks) Outline four qualities of @ good algorithm, (marks) Explain the role of each of the following header files ina C program: (1) stdio.f; (2 marks) (ii) math, (2 marks) Explain a circumstance under which each of the following Pascal keywords are most appropriate while programming: @ goto; (2 marks) fa) type. (2 marks) () © @ (b) @ (b) 2920/1038 sda 2018 In.an athictics competitions, athletes were awarded money based on the ranking as. shown in Table 2 (Rank Award (Kshs) 1 1000000 2 = 500000 250000 a Write a C program that would accept the rank, The program should then determine the award through the use of a function and display the results, Use ifstatemont. (8 marks) (i) Out (ii) Describe twa categories of data that could be used to test a program. (4 marks) two ways of checking the correctness of a prouriwm (2 marks) Explain a circumstance under which each of the fallowing parameter passing methods ee RWOSt appropriate: no . . (i) pass by value; " i - (2 marks) (ii) pass by reference, (2 marks) Distinguish between rechnica and wrer decumentation of a program, (4 marks) ‘Write a Pascal program that would aceeyta positive integer. The program should then determine the square of the number lay the number and its square through the use of a procedure, ~ (6 marks) (i) State two cea an be carried out in a queue data structure, ele ae om 2 marks) Gi) Describe a nk ee ‘as applied in programming. __ (2 marks) () State the meaning of each of the following file handling modes: Ld a Cl mark) Low (1 mark) “TL or (1 mark) Given that x is.a variable in C program that stores a numeric value, distinguish between x++ and ++ as used in the program operations, (4 marks) Oulling the steps involved in swapping two elements in an artay during sorting (4 marks) ‘With the aid of an illustration sort the following numbers in ascending order using a selection sort algorithm, (5 marks) 8, 4, 6, 12,32, 5 Code reusability is a popular trend used by programmers for quick program development. Outline four chazacteristies of such programs. (A marks) (i) Explain the term ravdiom access as used in file organization. (2 marks) 3 ‘Turn over (ii) Distinguish between gets) and px (98 applied in C programming language. (4 marks) (©) The following is a C program. Use it ta answer the question that follows: #includecstdio.h> int main() int %y,2z; x3, y=9, 20-5; (xesy)?12:9; ee return 0; } sing a trace table, show the values of x, y and z-for the program executions. (4 marks) (d) A text file named students txts located D has list of students, Write a Pascal Program that reads the file and displays the list on the screen. (6 marks) 7 (a) Explain the terra in-buaft function as used in C programming, 2 marks) (b) Distinguish between «record and am array data structure as used in peogrammning (4 marks) (J) G) Describe sequential search algorithm as used in programming, (2 marks) Gi) Using binary search algocith trate the steps used to search for a value 45 in the Following list of nun (6 marks) zs ~ 23 3048505 (@) Write a Pascal program th Id display all the odd numbers fiom | to 29 alongside their squares, Use the “wets (6 marks) 8. (a) State the function of each of the following C escape characters: @ in (1 mark) (i) (1 oiarky (b) (i) Write the general format far dect: ng a structure data type in C programs (4 marks) 4ii) Explain two reasons for using functions in a program. (4 marks) (©) With the aid ofa flowchart, describe a repeat nntil loop-as used in Pascal programs (4 marks) (4) Write a Pascal program that uses the for Joop to generate the following output, (6 marks) 1 1 I 1 2. z= z 2 3 3 3 3 124 won 4 4 4 4 ‘THIS IS THE LAST PRINTED PAGE, 2920/103 4 lal 2008

You might also like