# BIT1303A  BAC1203  BBIT105  PROGRAMMING METHODS,INTRODUCTION TO PROGRAMMING . KCA Past Paper UNIVERSITY EXAMINATIONS: 2016/2017
EXAMINATION FOR THE DEGREES OF BACHELOR OF SCIENCE IN
INFORMATION TECHNOLOGY/ APPLIED COMPUTING/ BUSINESS IT
BIT1303A BAC1203 BBIT105 PROGRAMMING METHODS
INTRODUCTION TO PROGRAMMING
FULLTIME/ PART TIME/ DISTANCE LEARNING
SUPPLEMENTARY/SPECIAL EXAMINATIONS
DATE: JULY, 2017 TIME: 2 HOURS
INSTRUCTIONS: Answer Question One & ANY OTHER TWO questions.

QUESTION ONE [30 MARKS]
a) Explain the following programming concepts;
i) Function (2 Marks)
ii) Symbolic constant (2 Marks)
iii) Pointer (2 Marks)
b) Define the term ‘operator’ and list THREE types of operators in programming (5 Marks)
c) Modern programming languages make use of control structures.
i) Explain the idea behind programming language control structures (2 Marks)
ii) Discuss and give examples of THREE major control structures used in C (9 Marks)
d) For each of the C libraries listed below, give a brief description of the library and its use.
Also provide an example of a function that the library uses and what this function does. The
first one has been done for you as an example.
i) <math.h> contains various mathematical functions. All the functions in this library take
double as an argument and return double as the result.
E.g., double sqrt(double x) — returns the square root of a double x
ii) <stdio.h>
iii) <stdlib.h>
iv) <string.h>
v) <ctype.h> (8 Marks)

QUESTION TWO [20 MARKS]
a) Using some code segment, describe the main components of a C program (6 Marks)
b) Explain any FOUR data types in C programming language (4 Marks)
c) Briefly comment each of the following lines of code. The first line has been done for you.
i) int x = 2; //Creates integer x and assigns it a value of 2.
ii) int *p;
iii) p = &x;
iv) *p = 4; (6 Marks)
d) To design good algorithms, we must measure them in terms of the computational resources
required by the algorithm. List FOUR of these computational resources (4 Marks)
QUESTION THREE [20 MARKS]
a) i) Define the term ‘Programming’ (2 Marks)
ii) Briefly describe the TWO approaches to modular programming (4 Marks)
b) Explain any FOUR features that make high level languages the preferred ones over machine
code and assembly programming languages (8 Marks)
c) i) Highlight THREE uses of functions in modern programming languages (3 Marks)
ii) Write a C main() function that finds the length of a typed string value (3 Marks)
QUESTION FOUR [20 MARKS]
A program is required to calculate an employee’s net salary from the gross pay. The net salary is
given by gross pay less deductions. Deductions include: 25% of gross pay as tax, KSh.250 as
NSSF contribution and KSh.320 as NHIF contribution.
a) Design an algorithm (flowchart OR pseudocode) to illustrate this program (5 Marks)
b) Implement the above program in C (15 Marks)
QUESTION FIVE [20 MARKS]
The electric company charges customers according to the following rate schedule for kilowatthours (kWh) used:
8 cents a kWh for the first 300 kWh
6 cents a kWh for the next 300 kWh (up to 600 kWh)
5 cents a kWh for the next 400 kWh (up to 1000 kWh)
3 cents a kWh for all electricity used over 1000 kWh
Write a complete C program to calculate the total charge for a customer. Your program should:
a) Obtain the kilowatt-hours used by a customer.
b) Calculate and the charge for electricity.
c) Display the charge in dollars with 2 digits after the decimal point. (20 Marks)

(Visited 109 times, 1 visits today) 