MACHAKOS UNIVERSITY
University Examinations for 2018/2019
SCHOOL OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF COMPUTING AND INFORMATION TECHNOLOGY
FIRST YEAR SPECIAL/SUPPLEMENTARY EXAMINATION FOR
BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY
SIT 106: PROGRAMMING METHODOLOGY
DATE: 22/7/2019 TIME: 2.00-4.00 PM
INSTRUCTIONS
Answer question ONE and any other TWO questions.
QUESTION ONE (30 MARKS, COMPULSORY)
a) Define the following
i. Identifier (2 marks)
ii. Variable (2 marks)
b) What rules are used in creating an identifier? (5 marks)
c) Give TWO examples for each of the following:
i. Data type (2 marks)
ii. Editor (2 marks)
iii. Compiler (2 marks)
d) Give TWO reasons why we declare variables in a program (4 marks)
e) Convert the following expressions into programming statements
i) xn (2 marks)
ii) m n− x (2 marks)
f) Describe the steps involved in programming (7 marks)
Examination Irregularity is punishable by expulsion Page 1 of 3
QUESTION TWO (20 MARKS)
a) Describe the loop control structure (8 marks)
b) Study the program below and answer the questions below
#include <iostream>
using namespace std;
int main()
{
int j;
for(j=0; j<15; j++)
cout << j * j << “ “;
cout << endl;
return 0;
}
i. What is the output of the program (3 marks)
ii. Rewrite the program using the do..while statement (4 marks)
iii. Draw a flow chart to represent the program above (5 marks)
QUESTION THREE (20 MARKS)
a) Describe Decision Making Control Structure (8 marks)
b) Given the following code fragment:
i. float p = 1.0; int n = 7; int x=2;
ii. for (int i=1; i<=n; i++) { if (n%2 == 1) p = p * x; cout << p << endl;}
c) What is the output of the program? (4 marks)
d) Express the output in terms of x (3 marks)
e) Draw a flow diagram to represent these structure (5 marks)
QUESTION FOUR (20 MARKS)
a) Using an example in each case explain the following terms as used in programming
i) Call-by-value (5 marks)
ii) Call-by-reference (5 marks)
b) Convert the following expressions to a programming statement:
i) mn + ex (5 marks)
ii) (5 marks)
Examination Irregularity is punishable by expulsion Page 2 of 3
QUESTION FIVE (20 MARKS)
a) Using an example explain the difference between a struct and a class (5 marks)
b) Write a function that can be used to find the greatest number among THREE floating
point numbers (6 marks)
c) Using examples of your choice explain what you understand by the following
i. method overloading (3 marks)
ii. accessor method (3 marks)
iii. mutator method (3 marks)
Examination Irregularity is punishable by expulsion Page 3 of 3