[go: up one dir, main page]

0% found this document useful (0 votes)
45 views5 pages

CSC 1106 Papera

Uploaded by

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

CSC 1106 Papera

Uploaded by

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

ISLAMIC UNIVERSITY IN UGANDA

FACULTY OF SCIENCE

END OF SEMESTER 1 EXAMS 2023/2024 SESSION

COURSE: BIT/CSC.

YEAR: I

PAPER: INTROODUCTION TO PROGRAMMING


AND PROBLEM SOLVING (CSC 2101)

DAY: TUESDAY

DATE: 12 DEC, 2023

TIME: 08:00 AM – 11:00 AM (3 HOURS)

READ THE INSTRUCTIONS CAREFULLY.

DO NOT WRITE ANYTHING ON THE QUESTION PAPER.


Instructions: Attempt two questions from each section
SECTION A
Question 1:
a) Express your understanding on computer programming and problem-
solving concepts (7 Marks)
b) Use an example to show how the six steps of problem solving can be
applied in a real-world scenario. (6 Marks)
c) Solutions can be algorithmic or heuristic, differentiate the two terms
giving an example for each (6 Marks)
d) Explain the guidelines of writing pseudo code and flow chart
(6 Marks)
Question 2:
a) With examples, differentiate between the following terms. (5 Marks)
i. Relational operators and Logical operator
ii. Operand and Resultant
b) Applications can be desktop, mobile, web-based or database. Explain any
two and give examples for each. (6 Marks)
c) Differentiate between encoding and decoding as used in programming
(4 Marks)
d) Fill in the following table with the variable name and data type needed to
solve an inventory problem for an Auto Supplies company.(10 marks)
Data Item Variable Name Data Type
Inventory item name
Inventory number
Quantity
Price
Date last ordered

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)

SECTION B (50 Marks)


Question 4:
The net salary of employees is calculated as described in the information
below;
i. The net salary is calculated as: net salary = (gross salary - taxes).
ii. Basic salary is a product of hours worked in a month and the rate per
hour which is 35000/-.
iii. Each employee is entitled to housing allowance and transport allowance
of 7% and 15.5% respectively of the basic salary.
iv. Gross salary is a sum of the basic salary and all the allowances.
v. The statutory taxes include PAYE. PAYE is computed as rate of tax of the
gross salary as indicated below;
Gross Salary Rate of Tax (%)
Up to 235,000 0
235,001 - 335,000 10
335,001 - 410,000 20
410,001 - 10,000,000 30
Above 10,000,000 40

a) You are required to come up with a pseudo code and a corresponding


flow chart for a program to accept the employee name and hours worked
from the user then computes and displays the following: (3 Marks)
i. Basic Salary (2 Marks
ii. Housing and transport allowances accordingly (5 Marks)
iii. Gross Salary (2 Marks)
iv. PAYE (5 Marks
v. Net Salary (2 Marks)

b) Program flow chart (6 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

(b) Write a program to the following;


i. Declare an array of strings of size 20 called studentnames.
(4 marks)
ii. Initialize the first three elements of the studentnames array with the
values: Musa, Mary, John and Sarah respectively. (6 marks)
iii. Write a for loop that can be used to print all the elements of the
studentnames array. (3 marks)

END

You might also like