MACHAKOS UNIVERSITY
University Examinations for 2020/2021 Academic Year
SCHOOL OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF COMPUTING AND INFORMATION TECHNOLOGY
FIRST/SECOND YEAR SPECIAL/SUPPLIMENTARY EXAMINATION FOR
BACHELOR OF SCIENCE (INFORMATION TECHNOLOGY)
BACHELOR OF COMMERCE
BMS 201/SIT 120: COMPUTER PROGRAMMING
DATE: 25/3/2021 TIME: 8.30-10.30 AM
INSTRUCTION: Answer Question ONE and any other TWO Question
QUESTION ONE- COMPULSORY (30 MARKS)
a) Distinguish between the following
i. Source code and object code (2 marks)
ii. Syntax error and logical error (2 marks)
iii. Primary and secondary memory (2 marks)
iv. For loop and while loop (2 marks)
b) Describe Three types of translators used in programming (6 marks)
c) Describe Three components of the structure of C program (6 marks)
d) Explain Five advantages of using preprocessor during program execution (5 marks)
e) Explain the action of the following codes:
i. int Sum=x+y+z; (2 marks)
ii. void main()
{
int a=10, b=2
int s= (a>b) ? a:b;
printf(“value is:%d”);
} (3 marks)
Examination Irregularity is punishable by expulsion Page 1 of 3
QUESTION TWO (20 MARKS)
a) Explain Five characteristics of a good algorithm (5 marks)
b) Explain the roles performed by the following in programming (4 marks)
i. Preprocessor:
ii. Link Editor
c) Describe Three types of Operators used in programming (6 marks)
d) Explain the purpose of the program below. If value 21 is entered into the program below,
what would be the output? (5 marks)
void main()
{
int n;
printf (“enter a number:”);
sacnf (“%d”, &n);
If (n%2==0)
printf (“even number”);
else
printf(“odd number”);
}
QUESTION THREE (20 MARKS)
a) Using suitable examples, describe Two types of functions used in programming (5 marks)
b) Given the program below, state Four good programming practices not adhered to. Examine
the program carefully and re-write the program using good programming practices. Explain
what the program actually does. (6 marks)
public class CL{public static void main(String [] args)
{char [] l={'a', 'b', 'c', 'a', 'e', 'a', 'g'};
int n=0;for (int i=0; i < l.length; i++){ if (l[i]=='a')n++;}
System.out.printf("Number of letter a = %d\n", n);} }
c) Outline the structure of a While Loop Syntax (4 marks)
d) Outline Five advantages of using high level languages in code writing (5 marks)
Examination Irregularity is punishable by expulsion Page 2 of 3
QUESTION FOUR (20 MARKS)
a) Write a C program to display the statement “welcome to my first program” (5 marks)
b) Write the syntax for declaring and initializing a single dimensional array (4 marks)
c) Draw a flowchart to add two numbers entered by user. (6 marks)
d) Outline Five input devices of a computer system (5 marks)
QUESTION FIVE (20 MARKS)
a) Write a C program to add two numbers (8 marks)
b) Describe the Three parts of a function (6 marks)
c) Explain the process of creating and running programs (6 marks)
Examination Irregularity is punishable by expulsion Page 3 of 3