(Knowledge for Development)
KIBABII UNIVERSITY COLLEGE
A CONSTITUENT COLLEGE OF
MASINDE MULIRO UNIVERSITY OF
SCIENCE AND TECHNOLOGY
UNIVERSITY EXAMINATIONS
2014/2015 ACADEMIC YEAR
FIRST YEAR SECOND SEMESTER
MAIN EXAMINATION
FOR THE DEGREE OF COMP SCIENCE & BIT
COURSE CODE: CSC 111
COURSE TITLE: INTRODUCTION TO COMPUTING
DATE: 4TH MAY, 2015 TIME 11.30AM-1.30PM
INSTRUCTIONS TO CANDIDATES
Answer Question One in Section A and Any other TWO (2) Questions in Section B
Instructions to candidates:
1
This paper consists of FIVE Questions.
Answer Question ONE [30 Marks] and any other TWO Questions [20 Marks Each].
Write your college number on the answer sheet.
This paper consists of 2 printed pages
Candidates should check the question paper to ascertain that all the pages are printed as
indicated and that no questions are missing.
© APRIL 2015 The KIBABII University College Examinations
SECTION A
Question 1: [30 MARKS] Compulsory
a)
i. Distinguish between a compiler and an interpreter (4 marks)
ii. Describe the term recursion and illustrate using suitable examples. (5 marks)
iii. Describe the difference between pass by value and pass by reference. Use a problem to evaluate the
area of a circle using a function getting data from main. (4 marks)
iv. Using an Example illustrate the nested loop programming concept. (2 marks)
b)
i. Explain the three types loops used in C programming language. (6 marks)
ii. Explain any three types of programming errors. (6 marks)
iii. Explain the function of the symbol } in C program (3 marks)
SECTION B: Answer any Two Questions from this section
Question 2: [20 Marks]
Describe the Five generations of computer programming languages; clearly highlight the characteristics, advantages,
disadvantages and Examples of each generation. (20 marks)
Question 3: [20 Marks]
a) With the aid of a flowchart, write a program in C language that allows a user to input any integer number then
determine if the number is a power of two. (10 marks)
b) Write a C program that finds the factorial of a given number N using recursive function. (10 marks)
Question 4: [20 Marks]
a) Write a program in C language using FOR loop that allows the user to input a number and produce a
multiplication table. (8 marks)
b) Analyze the programs 1 and 2 below and write the output:- (12 marks)
2
Program1 Program2
#include <stdio.h> #include<stdio.h>
Void main ( ) { void main(){
int i=1; int a=5,b=10;
for (k=1; k<10; k++) swap(&a,&b);
{ printf("%d %d",a,b);
i*=k; }
printf (“%d”, k,” \t”); printf (“%d”, i, “\n”); void swap(int *a,int *b)
} {
printf (“%d”, i); int *temp;
} *temp =*a;
*a=*b;
*b=*temp;
}
Question 5: [20 Marks]
a) Explain the program development Cycle. (10 marks)
b) Identify the errors in the following programs. (10marks)
Program1 Program 2:
#include<stdio> #include<stdio.h>
int main() int main ()
{ {
int a = 5; int i=1;
switch (a) while ()
{ {
case 1: printf ("%d\n", i++);
printf ("First") if (i>10)
case 2: break;
printf ("Second"); }
case 3 + 2: return ;
printf ("Third");
case 5:
printf("Final");
break;
}
return 0;
}