SCS1101201301 Introduction To Computer Science and Programming
SCS1101201301 Introduction To Computer Science and Programming
Instructions to candidate:
1. Answer all questions from Section A and any two from Section B.
2. All programming questions to be answered in C
3. Each questions contains 20 marks
3 HOURS
Section A
QUESTION ONE
b) Explain the two different types of errors in programming. Give examples in your
explanation. [6]
QUESTION TWO
a) Convert
i. 10010102 to base 4 [2]
ii. 1110.12 to base 16 [3]
Page 1 of 3
#include <stdio.h>
int main()
{
int i = 10;
do{
printf("Hello %d\n", i );
i = i -1;
}while ( i > 0 );
getch();
return 0;
}
d) Give the four data types in C and show how they are declared [4]
e) The size of a file is 14KB. Calculate the size of the file in bits. [3]
QUESTION THREE
Section B
QUESTION FOUR
a) Write a program that reads an integer and checks whether it is odd or even.
Show the algorithm for this program using a flow chart.
For example:
Enter a number: 25
25 is an odd number. [20]
Page 2 of 3
QUESTION FIVE
a) The wind chill index (WCI) is calculated from the wind speed v in miles per hour
and the temperature t in Fahrenheit. Three formulas are used, depending on the
wind speed:
if (0 <= v <= 4) then WCI = t
if (v >=45) then WCI = 1.6t - 55
otherwise, WCI = 91.4 + (91.4 - t)(0.0203v - 0.304(v)1/2 - 0.474). Write a
program that can calculate the wind chill index. [15]
QUESTION SIX
c) Write a C program that finds the greatest number from an array of 5 integers
[6]
Page 3 of 3