0% found this document useful (0 votes)
16 views2 pages

DIT 0202 Intro To Programming and Algorithms JAN April 2021 MAIN EXAM

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 DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

DIT 0202 Intro To Programming and Algorithms JAN April 2021 MAIN EXAM

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 DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

DEDAN KIMATHI UNIVERSITY OF TECHNOLOGY

University Examinations 2020/2021


STAGE II EXAMINATIONS FOR THE DIPLOMA IN INFORMATION TECHNOLOGY
DIT 0202: INTRODUCTION TO PROGRAMMING AND ALGORITHMS
DATE: March 2021 TIME: 1 hour 30 minutes
Instructions: Answer Question 1 and Any Other Two.

QUESTION ONE: 30 MARKS


a) Define the following terms as used in programming. [4 marks]
i. Comments
ii. Algorithm
iii. Header file
iv. Variable

b) Write a C program code that prompt you to enter your name and then displays it on the output
console. [3 marks]

c) Draw flowcharts showing programs flow for the following control statements.
i. while loop [3 marks]
ii. do while loop [3 marks]
iii. for loop. [3 marks]

d) Consider the following variables declared and initialized as shown below.


int x = 12; int y = 15; int z = 20;
Clearly showing your working, determine whether the following expressions are
true or false.

i) !(x < 10) && (y>21+4) [2 marks]


ii) (x <= 5 || y >15) && (z<40) [2marks]
iii) (x != 5) && (y == z) [2 marks]
iv) x<= z && (x + y >= z) [2 marks]

a) Write a C program to input temperature in Centigrade and convert to Fahrenheit [6 mrks]


Use Formula below

1
QUESTION TWO: 15 MARKS

a) Differentiate between the following terms used in programming. [8 marks]


i. Natural language and Programming language
ii. Syntax and semantics
iii. Syntax and semantic errors
iv. Object code and source code

b) Write a C program that display all numbers divisible by 5 between 0 and 100. [7 marks]

QUESTION THREE: 15 MARKS

a) Outline FIVE features of structured programming languages. [5 marks]

b) Write a C program code that computes the area of a rectangle, given its dimensions. It should first
prompt the user for the length and width of the rectangle and then displays the area.
[10 marks]

QUESTION FOUR: 15 MARKS

a) Explain the term Algorithm and describe THREE properties of a good algorithm [5 marks]

b) Wananchi Saving Society (wss) pays 5% interest on shares exceeding sh.100, 000 and 3% on shares
that don’t meet this target. However, no interest is paid on deposits in the members’ wss bank
account. Design an algorithm that would;
i. Prompt the user for shares and deposits of a particular member. [5 marks]
ii. Calculate the interest and total savings on the screen for a particular member of the society and
design the above flowchart [5 marks]

You might also like