UNIVERSITY EXAMINATIONS: 2017/2018
EXAMINATION FOR DEGREE OF BACHELOR SCIENCE/BUSINESS
BBIT 105&BIT 1303A-PROGRAMMING METHODOLOGY
MODE: FULL TIME/PART TIME/DISTANCE LEARNING
DATE: JULY, 2018 DURATION: 2 HOURS
INSTRUCTIONS: Answer Question ONE and any other TWO questions
QUESTION ONE [30 MARKS]
a) Briefly explain FOUR programming paradigms.
b) Explain why you might want to write a program in a machine independent language instead of a
machine dependent language.
c) Program errors can be syntax, logical, linker or semantic errors. Classify the following errors.
i). Misspelling keywords. 1 Mark
ii). Dividing a number zero. 1 Mark
iii). Using undeclared variable. 1 Mark
iv). Misspelling function name. 1 Mark
d) Write a C program to receive two integers using pointers then calculate and display the sum of the
e) Write a C program to store twenty natural numbers in a one dimensional array then calculate and
display the sum of the odd numbers that are members of this array.
f) Design a program using a flowchart to swap two values stored in two variables x1 and x1.
QUESTION TWO [20 MARKS]
a) Describe THREE basic data types in C while giving space occupied in memory by each.
b) Write a simple program to return memory addresses and size of the following variables:
i). int x; 2 Marks
ii). float y; 2 Marks
c) Describe TWO ways of creating a symbolic constant in C language
d) Write C statements for each of the following cases
i. Print three blank lines
ii. Read two integer values stored in variables a and b in one statement
iii. Display the value of a floating point variable in three decimal places.
QUESTION THREE [20 MARKS]
a) Using flowcharts, describe following program control structures characteristic of structured
i). Repetition structure
ii). Selection structure
iii). Sequential structure
b) Design a program using pseudo code to calculate and display the gross pay of fifty
employees given that gross pay=basic pay + allowances.
c) Implement the design in b) using C. The program should prompt the user to enter basic pay
and allowance, then calculate and display gross pay for all the fifty employees.
QUESTION FOUR [20 MARKS]
a) Differentiate between arguments and parameters as used in functions.
b) Design a program that uses functions to calculate the perimeter and area of a rectangle once
given dimensions. Hint: use a flowchart.
c) Implement the design in a) using C. The program should prompt the user to enter the
dimensions of the rectangle.
d) Write a program in c to pass an array containing age of a person to a function. The function
should prompt the user to enter age for all persons then find the average age and display the
average age in main function.
QUESTION FIVE [2 MARKS]
a) Discuss the four lexical elements of a C language.
b) You are required to write a program that uses structure called product whose members are
price and quantity. There are two objects (instances) of this structure namely soap and salt.
Assume price is of type float while quantity is of type integer.
c) Write a C program that uses two, one dimensional array to store 10 integers. Each of the element
stored in the first array is then modified by incrementing its value by 2 and the value stored in another
array. The program should display all the values in these two arrays.