CSC 1106 Papera
CSC 1106 Papera
FACULTY OF SCIENCE
COURSE: BIT/CSC.
YEAR: I
DAY: TUESDAY
Question 3:
(a) Define the following terms as applied in computer programming:
(i) Function (2 marks)
(ii) Function return type (2 marks)
(iii) Function parameter (2 marks)
(iv) Function body (2 marks)
(b) Explain at least three reasons why functions are important in
computer programming. (6 marks)
(c) Define the term array as applied in computer programming.
(2 marks)
(d) Give an illustration on how an array of integers of size 10 would be
represented in a computer memory. (4 marks)
(e) With the use of an example, show the difference between a variable
and an array (5 Marks)
Question 5:
You are required to write a pseudo code and a corresponding flow chart for a
program that implements the following;
I. Display a list of options:
1. Deposit
2. Withdraw
3. Check balance
Then ask the user to enter an option (i.e. 1,2,3). (4 Marks)
II. If the user enters 1, the program should ask the user to the enter deposit
amount and computes the balance, the minimum deposit amount is 5000,
otherwise it should display “Amount should be greater than or equal to
5000. (5 Marks)
III. If the user enters 2, the program should ask the user to enter the
withdraw amount and computes the balance only if the balance is more
than the withdraw amount, otherwise it should display “Insufficient
balance”. (5 Marks)
IV. If the user enters 3, the program should display the balance, otherwise the
program should display “invalid option”. (5 Marks)
V. Program flow chart. (6 Marks)
Question 6
a) A primary school at your local village has contacted you to help them
come up with a program logic and a flow chart that will help in solving
their problem basing on the following requirements.
I. Using a while loop, the program should be able to capture a student’s
score in five subjects. (5 Marks)
II. Then it computes the total and average scores of the five subjects.
(4 Marks)
III. Determines the student’s Division based on the following scale;
(6 Marks)
Average Division
>= 80 Division I
>=70 Division II
>=60 Division II
>= 50 Division IV
Below 50 Failure
IV. The program should then display the student’s total score, average
and division. (2 Marks)
b) Write program to do the following;
i. Define a function called CalculateArea() which takes two integer
parameters called base and height and is of the float return type.
(3 Marks)
ii. The function then calculates and returns the area using the formular
below:
iii. area = 0.5*base*height. (3 marks)
iv. Write two valid function calls to the above function using arguments
of your own choice. (2 marks)
Question 7:
(a) Write an if statement that can be used to print the name of the faculty
given the course code as shown in the table below. (12 marks)
S. No Code Faculty
1. 63011 Science
2. 63061 Science
3. 43011 Education
4. 43061 Education
5. 53011 Law
6. 53012 Law
7. 33011 Management
8. 33012 Management
END