Attempt Question 1 (Compulsory - 30 Marks) and Any Other TWO Questions (15 Marks Each)
Attempt Question 1 (Compulsory - 30 Marks) and Any Other TWO Questions (15 Marks Each)
Attempt Question 1 (Compulsory - 30 Marks) and Any Other TWO Questions (15 Marks Each)
INSTRUCTIONS:
Attempt Question 1 (compulsory - 30 marks) and any other TWO Questions (15 marks each).
(a) Explain the meaning of the following terms as used in programming (6 marks)
(iii) Function
(iv) Keyword
(v) Program
(d) Briefly explain any three characteristics of a good programming language (3 marks)
(e) Using examples, discuss three errors encountered in programming (4 marks)
(f) Tusaidiane Saving Society (TSS) pays 5% interest on shares exceeding sh.100, 000 and 3% on
shares that don’t meet this target. However, no interest is paid on deposits in the members’ TSS
bank account. Design a structured algorithm that would;
(i) Prompt the user for shares and deposits of a particular member. (2 marks)
Page 1 of 3
(ii) Calculate the interest and total savings for a particular member of the society (2 marks)
(g) Write a C program that allows the user to enter an integer number between 0 and 9. The integer
number is stored in a variable named n. Using the CASE statement identify the number entered. If
0, the program prints the message “you typed zero”, if 3, 5 or 7, the program prints the message
“n is prime number”, if 2, 4, 6 or 8, the program prints the message “n is an even number”, if 1 or
9, the program prints the message “n is a perfect square”, if none of the above, the program prints
the message "Only single-digit numbers are allowed”. (4 marks)
(c) In an Olympic event , medals are only awarded to the first three athletes as follows
(i) Using the Nested If structure, write a pseudo code to demonstrate the above. (4 marks)
(d) Write a C program that prompts the user to enter three numbers. The program should then check
the largest number among the three and then print the given numbers along with the largest
number. (3 marks)
(b) Explain the term program control structure and discuss three main control structures (4 marks)
(c) With the aid of a pseudo code and a flowchart, design an algorithm that:
(ii) Divide x by y, however if the value of y =0, then the program should display an error
division by zero (3 marks)
(d) John’s basic salary is input through the keyboard. His medical allowance is 40% of basic salary
and house rent allowance is 20% of basic salary. Write a C program to calculate his gross
salary (3 marks)
Page 2 of 3
QUESTION FOUR (15 mks):
(a) Explain why computer programs written in assembly languages or machine languages are
generally more efficient than those written in high level languages (3 marks)
(c) The distance between two cities (in km) is input through the keyboard. Write a C program to
convert and print this distance in meters, feet, inches and centimeters. (3 marks)
(d) Differentiate between user\programmer defined functions and inbuilt functions (2 marks)
(e) Write a C program that finds whether a number entered by the user is negative or positive.
(3 marks)
(b) Using examples in each case state, discuss the five classes of C operators (5 marks)
(c) Write a C program that calculates the absolute value of an integer entered by the user. Use the if
structure. (3 marks)
(d) A program is required to process and award students grades according to the following table
summary
MARKS GRADE
80-100 A
70-79 B
60-69 C
50-59 D
Below 50 E
(i) Write an algorithm that prompts the user to enter marks obtained by each student and then assign
and prints out the grade. Use the CASE structure (5 marks)
Page 3 of 3