# BIT1303A  BBIT105  BAC1203  PROGRAMMING METHODOLOGY.

UNIVERSITY EXAMINATIONS: 2017/2018
EXAMINATION FOR THE DEGREES OF BACHELOR OF SCIENCE IN
BIT1303A BBIT105 BAC1203 PROGRAMMING METHODOLOGY
FULLTIME/ PART TIME/ DISTANCE LEARNING
ORDINARY EXAMINATIONS
DATE: APRIL 2018 TIME: 2 HOURS
INSTRUCTIONS: Answer Question One & ANY OTHER TWO questions.

QUESTION ONE [30 MARKS]
a) Distinguish between the following terms as they apply to programming:
i) Function declaration and function call (2 Marks)
ii) Float and Double data types (2 Marks)
b) Recursion is the process by which a function calls itself repeatedly. Write a C program to
read an integer value between 0 to 20 and print its factorial using recursion. (8 Marks)
c) C Language programming is also called structured programming. What does it mean to say
that a language is “Structured Programming?” (6 Marks)
d) Using a nested do loop, write a C program to print the pattern below:
1 2 3 4
1 2 3
1 2
1
(5 Marks)
e) A programmer is person specialized in the technique of creating, maintaining and modifying
computer programs. Describe THREE types of programmers (3 Marks)
f) What is an array and how does it work? Illustrate this using an example (4 Marks)
QUESTION TWO [20 MARKS]
a) Differentiate between loosely typed and strongly typed programming languages. Give an
example for each type. (4 Marks)
b) Bitwise operators are operators used to perform bit operations. Decimal values are converted
into binary values which are the sequence of bits and bit wise operators work on these bits.
Given the variables A and B have initial values 123 and 23 respectively predict the output for
the following C statements:
i) printf(“%d”,A&B);
ii) printf(“%d”,A|B);
iii) printf(“%d”,A<<2); (6 Marks)
c) Distinguish between whitebox and blackbox testing and list TWO advantages of each
strategy (6 Marks)
d) Write a program in C to accept a given integer from a user and then display the cube of
numbers starting from 1 up to this given integer. (4 Marks)
QUESTION THREE [20 MARKS]
a) Using an example of assignment operators, differentiate between operator order of
precedence and associativity. (6 Marks)
b) Using break and continue statements, write a simple C program that divides two integers
entered by the user and displays the result under the following conditions.
If one of the two integers is zero, then result will not be displayed but the program should
not terminate.
If any of them is negative, then the program should terminate. (6 Marks)
c) Discuss any FOUR characteristics of a good algorithm (4 Marks)
d) Write a program to check whether a given number is a perfect number or not, then display
this information to the user. Note: A perfect number is a positive number which sum of all
positive divisors excluding that number is equal to that number. For example 6 is perfect
number since divisor of 6 are 1, 2 and 3. Sum of its divisor is 1 + 2 + 3 = 6 (4 Marks)
QUESTION FOUR [20 MARKS]
b) Distinguish between the following:
i) Algorithm and Code-listing
ii) Signed and Unsigned data types (4 Marks)
c) Assuming that m and n have been initialized to zero, what is the value of a, m and n after
evaluation for the following expression?
i) ? = ? + + + ? + +
ii) ? = + + ? + + + ? (4 Marks)
d) A program is required to ask for the president of Russia under the following conditions:

If the user enters “Vladimir” or “Putin” or both, a message “You answered correctly”
should display and the program should terminate.
If the user gives any other answer, the program should display “Incorrect answer, try
again” and allow the user to input another answer.
If the user enters an incorrect answer three times, the program should display “The
Required:
i) Design a suitable algorithm in the form of flowchart or pseudocode to illustrate this
problem (4 Marks)
ii) Write code to implement the solution (6 Marks)
QUESTION FIVE [20 MARKS]
a) What is the result of x after evaluation of the following expression? (Assume n and m
have been initialize to 3 and 5 respectively and that they are x, n, and m are integers)
i) x=n%m
ii) x=n/m (4 Marks)
b) The formula for computing value of x called ‘root’ for the relationships y=ax2+bx+c is
given as

Required:
i) Write an algorithm (flowchart or pseudocode) to solve the roots above (4 Marks)
ii) Write a C program to compute the roots of a quadratic equation (6 Marks)
c) Functions are at the core of C programming. Identify and briefly describe THREE
standard string functions used in C (6 Marks)

(Visited 62 times, 1 visits today)