UNIVERSITY EXAMINATIONS: 2013/2014
ORDINARY EXAMINATION FOR THE BACHELOR OF SCIENCE
IN INFORMATION TECHNOLOGY
BIT 1303A PROGRAMMING METHODS
DATE: APRIL, 2014 TIME: 2 HOURS
INSTRUCTIONS: Answer Question ONE and any other TWO
QUESTION ONE
(a) Define the following as they apply to programming [5 Marks]
(i) Flowchart
(ii) Pseudocode
(iii)Object code
(iv)Pointer
(v) Pre-processor directive
(b) Name any four rules adopted in naming variables [2 Marks]
(c) A program is required to calculate and output the sum and product of all odd
integers between 39 and 87 inclusive.
As part of your solution to the problem above, write: [5 Marks]
(i) An algorithmic solution for your answer
(ii) Draw a flow chart to represent this
(d) Differentiate between the following [6 Marks]
(i) Keyword and identifier
(ii) Function prototype and function definition
(iii)define and include preprocessor commands
(e) Write a program segment that does the following; [9 Marks]
(i) Initialize the 5 element of an integer array count to zeros
(ii) Add 2 to each of the 5 elements of the array count
(iii)Print the 5 values of the array count sorted in ascending order
(f) Differentiate between a struct and a Union [2 Marks]
(g) Define a pointer showing how an describing how and integer pointer is
initialized [1 Marks]
QUESTION TWO
(a) Make a structure declaration for an ACCOUNT with the following members
Accno
Balance
Acc_name
[4 Marks]
(i) Using the structure defined above, write a statement that creates a
structure variable called Saving_Account [2 Marks]
(ii) Using the variable, write a program segment to perform the each of
following
Access the structure member balance and assign to it the value 200
Read a name through the keyboard and store it in the address for
account name
[5 Marks]
(b) Define what you understand by the following concepts [4 Marks]
(i) Modular programming
(ii) Structured Programming
(c) Explaining whether the following statements are valid or invalid [5 Marks]
(i) int =0 total;
(ii) float total@
(iii)sum+=k;
(iv)define const pi 3.14;
(v) include “c:\first.c”
QUESTION THREE
(a) Structured programming is characterized by the following;
(i) Variables
(ii) Control structures
(iii)Assignments
(iv)Modules
Explain the role played by each of the above features [16 Marks]
(b) List and briefly explain 2 ways that data is shared in C [4 Marks]
QUESTION FOUR
(a) A program is required to compute the sum of even numbers between 30 and 366.
(i) Write a pseudocode as part of the solution to this problem
(ii) Draw a flowchart to depict solution to the problem
(iii)Implement the above using C
[8 Marks]
(b) Explain with a diagram how a while control construct differs from a do while
[4 Marks]
(c) Give one similarity and 3 differences between a compiled and interpreted
Language [4 Marks]
(d) Define what a comment is in C and their importance [4 Marks]
QUESTION FIVE
(a) Define the following [6 Marks]
(i) Function prototype
(ii) Function call
(iii)Function definition
(b) Write a program that can be used to get the area and volume of a cylinder (Hint:
area=2 PI r(r + h) and volume=PI r2 h)
As a solution to the problem, write a function AREA and VOLUME to return
the respective values. These functions are called via main () [11 Marks]
(c) Define the following
(i) Syntax
(ii) Semantic
(iii)Programming Language
[3 Marks]