0% found this document useful (0 votes)
10 views

CSC 111 Introduction To Programming A Questions

The document contains instructions for an exam on Introduction to Computing. It includes 5 questions, with Question 1 being compulsory and consisting of multiple parts on topics like compilers vs interpreters, recursion, pass by value vs reference, and nested loops. The other questions cover generations of programming languages, writing programs to check if a number is a power of two, calculating factorials recursively, writing programs to produce multiplication tables and swap values, and describing the program development cycle and identifying errors in code samples.

Uploaded by

mdigojuma01
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

CSC 111 Introduction To Programming A Questions

The document contains instructions for an exam on Introduction to Computing. It includes 5 questions, with Question 1 being compulsory and consisting of multiple parts on topics like compilers vs interpreters, recursion, pass by value vs reference, and nested loops. The other questions cover generations of programming languages, writing programs to check if a number is a power of two, calculating factorials recursively, writing programs to produce multiplication tables and swap values, and describing the program development cycle and identifying errors in code samples.

Uploaded by

mdigojuma01
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

(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;
}

You might also like