Sit106 Programming Methodology 2
Sit106 Programming Methodology 2
Supplementary/Special Examination
SCHOOL OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF COMPUTING AND INFORMATION TECHNOLOGY
Instructions
This paper consists of FIVE questions.
Answer QUESTION ONE and other TWO questions in this paper.
Question One
(a) (i) Define the term programming translation as used in computer programming. (2 marks)
(b) Tom, a programmer wrote an algorithm for a program. Explain three characteristics of
algorithms he could have considered. (6 marks)
(c) (i) During a programming lesson, students incorporated comments in their program.
I. Explain the term comment as used in the statement. (2 marks)
II. State two ways through which comments are included in a C program.
(2 marks)
(ii) An organization has tasked you with writing a good program for them. Explain three
qualities you would consider. (6 marks)
(ii) Write a program in C language that would prompt a user to enter an integer. The
program then checks whether the integer entered in even or not and outputs the result.
(6 marks)
1
Question Two
(a) (i) Outline two disadvantages of using machine code when writing a program. (2 marks)
(ii) The following program segment created by a student has some syntax errors. Use it to answer
the question that follows.
Include<stdio.h>
int Main ( )
float x, y product
scanf(“%d%d\n a, b);
product = x * y;
printf(product);
Rewrite the program correctly. (4 marks)
(b) Computer programming have evolved over time. Discuss two paradigms that have been part
of this evolution. (4 marks)
(c) (i) Distinguish between call by value and call by reference as used in programming. (4 marks)
(ii) Write a program in C language that would prompt a user to enter distance in meters. The
program then converts the distance entered into kilometers through a function and outputs the
result. (6 marks)
Question Three
(a) The following are variable names used by a student in a C language program.
(i) Try out
(ii) Mashunjaa_Day
(iii) StudentDetails
(iv) with
State the validity of each of the variables giving a reason for your answer. (4 marks)
(c) The following is an output from a computer program. Use it to answer the question that follows:
5
6 6
7 7 7
Write a program in C language that would generate the output. (4 marks)
(d) (i) Define the term function call as used in programming. (2 marks)
(ii) A program accepts two integers, it checks which of the two integers is larger than the other
and outputs the result. Draw a flow chart to represent the program logic. (4 marks)
2
Question Four
(a) Outline three operations carried out on a queue data structure. (3 marks)
(b) Write a program in C language that would store five elements in an array and output the elements in
reverse order of entry. (6 marks)
(d) A university has installed a program that allows lecturers to key in marks for students. When a
registration number is entered the program checks whether the student has cleared the semester fee.
If a student has cleared then the lecturer keys in the marks otherwise a “NOT CLEARED” message
is displayed. Write a pseudocode for this scenario. (5 marks)
Question Five
(a) (i) Define the term pointer as used in C language programming. (2 marks)
(ii) Write a C language statement to declare a pointer to a float variable name Number and assign
it the memory address 2150. (3 marks)
(b) (i) Outline the three levels of computer programming languages. (3 marks)
(ii) Explain three characteristics of a fourth-generation programming language. (6 marks)
(c) Table 1 shows the approval criteria used by a certain bank. Use it to answer the question that
follows.
Write a program in C language that would prompt a user to enter the evaluation result. The program
then outputs the loan limit for the applicant. Use switch control structure. (6 marks)