0% found this document useful (0 votes)
116 views4 pages

Comp 120inte 124 Structured Programming

The document outlines instructions for an examination on structured programming at Kabarak University. It provides 5 sections with multiple choice and written questions testing concepts like functions, loops, arrays, pointers and more. Students are instructed to answer Section A and any two questions from Section B.

Uploaded by

benkim739
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
116 views4 pages

Comp 120inte 124 Structured Programming

The document outlines instructions for an examination on structured programming at Kabarak University. It provides 5 sections with multiple choice and written questions testing concepts like functions, loops, arrays, pointers and more. Students are instructed to answer Section A and any two questions from Section B.

Uploaded by

benkim739
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

KABARAK UNIVERSITY

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

COMP 120/INTE 124/BBIT 124/COSF 121: STRUCTURED


PROGRAMING

STREAM: (Y1S2 &Y2S1) REGULAR TIME: 9:00 - 11:00AM


EXAMINATION SESSION: JAN.-APRIL DATE: 21/04/2023
INSTRUCTIONS TO CANDIDATES
1. Answer Question 1 and any other two questions in the answer booklet provided.
2. Do not write on your question papers. All rough work should be done in your
answer booklet.
3. Clearly indicate which question you are answering.
4. Write neatly and legibly.
5. Follow all the instructions in the answer booklet

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)

SECTION B. TOTAL MARKS FOR THIS SECTION IS 40.


ANSWER ANY TWO QUESTIONS FROM THIS SECTION. EACH QUESTION IN
THIS SECTION CARRIES 20 MARKS.
2.
a) Demonstrate the use of a switch statement to test as to which of the characters a, b and c
has been entered from the keyboard. (4 marks)
b) Write a code in C language to swap two integer numbers entered from the keyboard
(4 marks)
c) i) Explain what a Pointer is in C language (2 marks)
d) ii) Consider the following statement and determine the value of c: (4 marks)
int quantity, *p, c;
quantity = 100; p = &quantity;
c = *p;
e) i) Explain what an array is in C programming (2 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)

c) Write a C program to compute length of a string formed by concatenating two


strings (5 Marks)
d) Vumilia shop provide after sales services according to the following criteria.

Value of goods in Ksh. Item to be given


1000 to 2000 a pen
2001 to 3000 loave of bread
3001 to 4000 ½ litre cooking oil
4001 to 5000 a packet of flour
Above 50001 1 litre cooking oil
Write the program for the above criterion using arrays (6 marks)
4.
a) Define any FOUR (4) types of tokens available in C programming language
(4 marks)
b) Write a program to test if a given number is ODD or EVEN. (4 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

You might also like