0% found this document useful (0 votes)
77 views4 pages

CIT 1101 Introduction To Programming Odinary Exam Print

Uploaded by

ioenga741
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views4 pages

CIT 1101 Introduction To Programming Odinary Exam Print

Uploaded by

ioenga741
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

DEDAN KIMATHI UNIVERSITY OF TECHNOLOGY

University Examination 2020/2021

YEAR I SEMESTER I ORDINARY UNIVERSITY EXAMINATION FOR THE bacheror OF


SCIENCE IN INFORMATIONB TECHNOLOGY

CIT 1101: INTRODUCTION TO PROGRAMMING

DATE: 30th November, 2020 TIME: 8.30am-10.30am

INSTRUCTIONS:

Attempt Question 1 (compulsory - 30 marks) and any other TWO Questions (20 marks each).

Question One [30 Marks]

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

c) Write C statements that can be used to do the following:

i) Declare an array MyNumber of 5 components of type int. (2mks)


ii) Set the value of the 9th component of MyNumber array to 27. (2mks)

d) i) Outline one difference between a compiled and an interpreted program. (1mk)


ii) Explain any two advantages that compiled programs have over interpreted programs.
(2mks)

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.

Draw a flowchart to represent this scenario. (3mks)

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)

h) Outline the three steps followed in solving a programming problem. (3mks)

Question Two [20 marks]

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(This is a simple program ”);

printf(“to display a message. \n”);

orite number is %d because ”, num);

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)

Question Three [20 Marks]

a) Write a program to demonstrate the concept of function overloading by incorporating two


functions named Square() to calculate and return the area and the perimeter of the a square
respectively. (9mks)

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)

Question Four [20 marks]

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

You might also like