CIT 1101 Introduction To Programming Odinary Exam Print
CIT 1101 Introduction To Programming Odinary Exam Print
INSTRUCTIONS:
Attempt Question 1 (compulsory - 30 marks) and any other TWO Questions (20 marks each).
a) Explain the use of the keyword void as a type specifier in a function. (2mks)
b) An intern has been recruited at Dedan Kimathi University and has approached you to
introduce him to the basics of computer programming before he starts his duties. Explain
to him the meaning of the following the terms (2mks)
i) Translator
ii) Pseudo code
iii) Flowchart
iv) Syntax
Page 1 of 4
e) Indicate whether the following C statements are syntactically correct. Give reasons for
your answer. (3mks)
a) char grade = A;
b) numbers [];
c) x+13 = z;
f) Consider the scenario below and answer the questions that follow:
In a football match, if a player does a mistake which is considered serious by the rule
of the game he/she is given a Red card otherwise a Yellow card.
g) The table below shows the grading criteria used at Dedan Kimathi University for awarding
students grades for marks in various units. Use it to answer the questions that follow.
MARKS GRADE
70-100 A
60-69 B
50-59 C
40-49 D
0-39 E
i) Design a pseudo code that can be used to grade and print a student’s marks
following this criteria. (5 mks)
ii) Translate the above pseudo code into a C program. (5 mks)
a) Differentiate between the bottom up and the top down approaches of program development.
(4mks)
b) Debugging means detecting, tracing, and correcting errors (bugs) in a program. Using
appropriate examples explain any two types of programming errors. (4mks)
Page 2 of 4
c) You have been invited for an interview for the position of a programmer in ABC Company.
During the interview session the panel has given you the program below to study. Identify and
explain any three syntax or logical errors in the program. (3mks)
#include<stio.h>
main()
int num;
num = 1;
printf(“ it is first.\n ”)
return 0;
c) Write a program that can be used to grade the marks of a student using a nested
if…else..statement. Use the grading criteria shown below. (6 mks)
0 – 39 E
40 – 49 D
50 – 59 C
60 – 69 B
70 – 100 A
f) Outline any three rules observed in variable declaration. (3mks)
Page 3 of 4
b) Using relevant code snippets examples demonstrate how C programs implement bifurcations
and control jumps in its iteration statements. (6mks)
c) Explain the general syntax for the case (switch) statement as used in a C program. (5mks)
a) Write a program to display all odd numbers between 53 down to 21 inclusive using a do…while
…statement. (5mks)
b) Write a program that initializes 5 elements of a one dimensional array dynamically and then
displays sum of the elements and their mean. (5mks)
c) Write a program that mimics an electronic calculator by reading two values from the keyboard
and operating upon them based on the operator keyed in.e.g if the user keys in % operator the
program should return the modulus. (6mks)
d) Outline any two differences between the first and the third generations of computer
programming languages. (4mks)
Page 4 of 4