BBIT 105 PROGRAMMING METHODOLOGY DISTANCE LEARNING KCA Past Paper

UNIVERSITY EXAMINATIONS: 2014/2015
ORDINARY EXAMINATION FOR THE BACHELOR OF BUSINESS
INFORMATION TECHNOLOGY
BBIT 105 PROGRAMMING METHODOLOGY DISTANCE
LEARNING
DATE: APRIL, 2015 TIME: 2 HOURS
INSTRUCTIONS: Answer Question ONE and any other TWO

QUESTION ONE [30 MARKS]
a) Define the following terms as used in programming
i). Null statement
ii). Comment
iii). Pointer
iv). Array [8 Marks]
b) Explain four rules that must be followed when naming a variable in C. [4 Marks]
c) Write a program in C that reads the user input and then uses switch case to display a
message using the criteria below.
User input message
A Very hot
B Hot
C Warm
D Cold
[8 Marks]
d) Write a program in C that gets thirty eight scores keyed in by the user, then stored in
an array called games. During function call, the array is passed to a function that calculates and returns the total score to the main function using call by reference.
[8 Marks]
e) Discuss the term indirection as used in pointers. [2 Marks]
QUESTION TWO [20 MARKS]
a) Explain any two advantages of procedural programming paradigm. [4 Marks]
b) Explain why a programmer must design and analyze a program before the actual coding. [4 Marks]
c) Differentiate between pseudo code and flowcharts as program design tools.
[4 Marks]
Design a program using a flowchart to get temperature in degree Fahrenheit then convert
to degree Celsius, using the formular ( 32)
9/5
C = F − where C is temperature in degree
Celsius and F is temperature in degree Fahrenheit. [8 Marks]
QUESTION THREE [20 MARKS]
a) Differentiate between pass by value and pass by reference as used in function call.
[4 Marks]
b) Write a program in C that gets twenty (20) integer values to be stored in a one dimensional array in main function then pass this array to a function called sum that adds all
the array values and returns the final result to the main function. [10 Marks]
c) Explain three advantages of functions in a C program. [6 Marks]
QUESTION FOUR [20 MARKS]
a) Compare and contrast the do and while loops. [4 Marks]
b) Write a program in C that prints odd numbers between 1 and 1000 using a do loop.
[8 Marks]
c) Write a program in C that gets user input for a body temperature then uses a condition
operator?: to display the message “you are ok” if the body temperature is less than or
equal to 37°C and “you need to see a doctor” otherwise. [8 Marks]
QUESTION FIVE [20 MARKS]
a) For each of the following cases write an appropriate statement in C.
i). Get user input of an integer value of variable num1. [2 Marks]
ii). Display a floating point value variable num2 in three decimal places.
2
[2 Marks]
iii). Write a formula to calculate the value of v in the expression
xv − y=30
[ 2 Marks]
b) Explain the output of the following program in C
#include<stdio.h>
int main()
{
int x;
x=12;
printf(“%d\n”,x);
printf(“%d\n”,–x);
x%=3;
printf(“%d\n”,x–);
x*=3;
printf(“%d\n”,++x);
printf(“%d\n”,x++);
printf(“%d\n”,x);
return 0;
}
[8 Marks]
c) Write a program in C that uses a symbolic constant for speed of light 8 C = 3Χ10 to
calculate the kinetic energy of an electron moving at the speed of light given that this
energy can be calculated using the formular KE= where m is the mass of the
electron and c is the constant (speed of light). The user will only be required to key in
the value of m. [6 Marks]

(Visited 61 times, 1 visits today)
Share this:

Written by