Comp 120inte 124 Structured Programming
Comp 120inte 124 Structured Programming
UNIVERSITY EXAMINATIONS
MAIN CAMPUS
FIRST SEMESTER, 2023 ACADEMIC YEAR
EXAMINATION FOR THE BACHELOR OF BUSINESS
MANAGEMENT INFORMATION TECHNOLOGY/BACHELOR OF
SCIENCE IN INFORMATION TECHNOLOGY/BACHELOR OF
BUSINESS INFORMATION TECHNOLOGY
As members of Kabarak University family, we purpose at all times and in all places, to set apart in one’s heart,
Jesus as Lord. (1 Peter 3:15)
Kabarak University is ISO 9001:2015 Certified
Page 1 of 4
SECTION A: (Compulsory) TOTAL MARKS FOR THIS SECTION IS 30.
1.
a)
i. List down four user defined functions used in C? (2 marks)
ii. Write a program where the main() function calls a user defined function known as
new( ) that adds 2 and 7 and returns the result to the main function to display it as
output. (5 marks)
b) Define the following terms
i. Algorithm (1 mark)
ii. Programming (1 mark)
iii. State the function of return statement (2 marks)
c)
i. Explain the differences between a while loop and a do while loop. (3 marks)
ii. Use a while loop to write a program in C to display the following output: 3, 4, 5,
6,7, (6 marks)
d) Explain four logical operators usually used in C language, and sketch a code to show
how each is used. (4 marks)
e) Outline the benefits of using pointers in C programs. (6 Marks)
As members of Kabarak University family, we purpose at all times and in all places, to set apart in one’s heart,
Jesus as Lord. (1 Peter 3:15)
Kabarak University is ISO 9001:2015 Certified
Page 2 of 4
ii) Given the following code, show the output when this program is executed. (4 marks)
#include <stdio.h>
void display(int a1, int a2)
{
printf("%d\n", a1);
printf("%d\n", a2);
}
int main() {
int Array[] = {2, 11, 4, 20};
display(Array[1], Array[3]);
return 0;
}
3.
a) Discuss the advantages of structured programming (4 marks)
b) Write a program to display the SUM of even numbers between 20 and 40 and
display them in descending order. (5 marks)
As members of Kabarak University family, we purpose at all times and in all places, to set apart in one’s heart,
Jesus as Lord. (1 Peter 3:15)
Kabarak University is ISO 9001:2015 Certified
Page 3 of 4
c) List any FOUR (4) types of predefined functions used in C programming language.
(4 marks)
d) Write a program to accept a number 679 and find the sum and average of the
individual digits of that number. (4 marks)
e) Write a C program to find the area of a rectangular playing ground with dimensions
of 40 by 60 meters. (4 marks)
5.
a) Explain the differences between Formal parameters and Actual parameters
(4 marks)
b) Write a program that would determine if a character entered is a number or not.
(6 marks)
c) Write a simple program to display the first ten natural numbers (4 marks)
d) Write a program to show how a SYMBOLIC constant is used C programming
(6 marks)
As members of Kabarak University family, we purpose at all times and in all places, to set apart in one’s heart,
Jesus as Lord. (1 Peter 3:15)
Kabarak University is ISO 9001:2015 Certified
Page 4 of 4