SPC 2107 introduction to computer programming year I semester
SPC 2107 introduction to computer programming year I semester
Page 1 of 4
#include stdio.h
main
int number;
printf (“enter an integer number”)
scanf(“%”,&number
if(number<100
printf “your number is smaller than 100”
else
printf(“your number contains more than two digits”)
d) Describe the use of the following escape characters and format specifiers used in C
language (4 marks)
i) \n
ii) !=
iii) \t
iv) %d
e) Write a C program that reads the radius of a sphere and calculate the volume.
Where volume =4/3 r3. (6 marks)
f) In C language identifiers are the names given to variables, constants, functions, and
user-defined data. Give four rules applied when naming an identifier.
(4 marks)
a) C has various standard data types that are used to define the operations possible on
them and the storage method for each of them. Explain five data types used in C
language. (10 marks)
b) Kirinyaga University has hired you to write a program that will help implement a
grading system for students. The examination department has provided you with
the rules for grading as shown in the table below. Write a C program to help
implement the grading system. (10 marks)
Page 2 of 4
Grades Score
A 70-100
B 60-69
C 50-59
D 40-49
E(Fail) Below 39
Page 3 of 4
QUESTION FOUR: (20 MARKS)
a) Write a C program that computes the area and perimeter of a rectangle. Prompt the
user to enter the length and width of the rectangle (10 marks)
int i=1;
while(i<=10){
if(i<8&&i!=2||i%4!=0)
printf("%d",i--);
i++
}
c) Write a C program to check if a number is divisible by 11 or not (5 marks)
a) Draw up a flowchart for entering a student marks, process and provide Output. If
the marks are greater than 40 and repeat if the total marks in less than 40.
(10 marks)
b) An electric motor rotates 1000 times in a minute. every time it rotates it moves a
robot 2cm from its current location. Write a c program that will show distance in M
that the robot will have covered one hour after the motor started rotating.
(10 marks)
Page 4 of 4