W1-2-60-1-6
JOMO KENYATTA UNIVERSITY
OF
AGRICULTURE AND TECHNOLOGY
UNIVERSITY EXAMINATIONS 2015/2016
FIRST YEAR SECOND SEMESTER EXAMINATION FOR THE DEGREE
OF BACHELOR OF BUSINESS INFORMATION TECHNOLOGY/
BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY
ICS 2102: INTRODUCTION TO COMPUTER PROGRAMMING
DATE: DECEMBER 2015 TIME: 2 HOURS
INSTRUCTIONS: ANSWER QUESTION ONE (COMPULSORY) AND
ANY OTHER TWO QUESTIONS
QUESTION ONE (COMPULSORY) (30 MARKS)
a) Discuss the steps that are followed when executing a C program. [5 marks]
b) The basic structure of a C program comprises of different elements.
Discuss these elements. [5 marks]
i) Preprocessor Statement
ii) Main ( )
iii) Declaration and Statement
iv) User defined functions
v) A pair of curly braces { }
c) Explain any FIVE characteristics of a C program. [5 marks]
d) Differentiate between the following set of programming terms: [4 marks]
i) Variable and Identifier
ii) Operand and operator
e) What are the rules for constructing variable names? [4 marks]
f) Write a C program to find Gross salary, given Gs = bs + da + ta;
da = (10 x bs)/100, ta = (12 x bs)100. [5 marks]
g) Explain the following terms as used with regards to functions. [2 marks]
i) Call by reference
ii) Call by value
1
QUESTION TWO (20 MARKS)
a) List atleast an advantage and disadvantage of madine language,
and thereafter go ahead and give one advantage of introducing
assembly language. [3 marks]
b) What is a variable? [1 mark]
c) Contrast the features of a compiler and interpreter as used in high
level languages. [4 marks]
d) Write a program in C to convert the temperature from centigrade
to Fahrenheit; given formula s f = (1.8 x c) + 32. [6 marks]
e) Write a C program to calculate sum of 5 subjects and find percentage. [6 marks]
QUESTION THREE (20 MARKS)
a) What do the below character combinations mean. [4 marks]
i) ‘\t’
ii) ‘\n’
iii) ‘\f’
iv) ‘\a’
b) Write a program to read four numbers and print the greatest of
the given four numbers. [4 marks]
c) Use the If the else statement to write a program to read a year and
find whether the given year is leap or not the general Format used
to create frames in a HTML document. [6marks]
d) Write a program in C to display Name of student, Reg. No.,
Academic year, Course of student. [6 marks]
QUESTION FOUR (20 MARKS)
a) Use the for loop to write a C program to print sum of natural
number from 20 -30. [6 marks]
b) What are the steps taken in the execution of the for statements. [3 marks]
c) Write a program in C language to accept a number and print the
mathematical table of the given number. [6 marks]
d) Use the switch statement to write a program that accepts 5 single
digit numbers and prints them in words. [5 marks]
2
QUESTION FIVE (20 MARKS)
a) What are the rules for writing the switch statement. [5 marks]
b) Write a program to accept values into 3 x 2 array and print. [5 marks]
c) Why do we need user defined functions in C programming? [4 marks]
d) Write a program to accept two numbers and print the sum of two
numbers using functions. [6 marks]