SCHOOL OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF COMPUTING AND INFORMATION TECHNOLOGY THIRD YEAR SPECIAL/SUPPLEMENTARY EXAMINATION FOR BACHELOR OF SCIENCE (INFORMATION TECHONOLOGY) SCO 102/SIT: INTRODUCTION TO PROGRAMMING DATE: TIME: INSTRUCTIONS: Answer Question ONE and any other TWO Questions
QUESTION ONE (COMPULSORY) (30 MARKS)
a) Define the following terms as used in Programing. (2 marks) i) Program ii) Programming Language
b) Interpret the following sample program line by line. (4 marks)
#include <stdio.h> main() { int *p, q; q = 100; /* assign q 100 */ p = &q; /* assign p the address of q*/ printf(“%d”, *p);/* display q’s value using pointer*/ return 0; } c) Using an example explain operator and operand (4 marks) d) What is the difference between source code and Object code? (4 marks)
e) Differentiate between a variable and a constant. (4 marks)
f) C Language is Portable and efficient. Explain (4 marks)
g) Suggest, with examples two ways in which constant values can be used in C expression statements. (4 marks)
Examination Irregularity is punishable by expulsion Page 1 of 3
h) Use the following code to identify syntactical error. (4 marks) Code snippet <stdio.h> #define PI 3.14 main() { FLOAT radius, 1area printf(“Enter the radius of the circle \n”); scanf(“%f”, &radius); area = PI * radius * radius; /* PI is a symbolic constant */ printf(“Area is %f cm squared “,area); return 0; } QUESTION TWO (20 MARKS) a) A program is required that accepts the radius and height of a cylinder and computes the volume. Use a function to achieve this. (8 marks) b) Describe with examples, four relational operators. (4 marks)
c) Using an example compare if—else and nested—if. (8 marks)
QUESTION THREE (20 MARKS)
a) Define the term function as used in programming. (2 marks) A program is required that accepts marks a student gets in four units and computes the average. Depending on the average the student is graded according to the table below. 70-100 =A 60-69=B 50-59=C 40-49=D 0-39=F b) Write a C program to achieve the above task. (8 marks) c) What is an array? (2 marks) d) After writing a code your friend a programmer complained because the program was not readable. Using example discuss how you can address this problem. (4 marks) e) What is the difference between global and local variable? (4 marks)
QUESTION FOUR (20 MARKS)
a) During a task to develop a program you chose C language. Explain advantages of C as a programming language. (10 marks) b) You are required to write a program that displays the days of the month. Use array to achieve this. (6 marks) c) Distinguish between assembly language and Machine Language in programming. (4 marks)
Examination Irregularity is punishable by expulsion Page 2 of 3
QUESTION FIVE (20 MARKS) a) Explain TWO Advantages of modular programming. (2 marks)
b) Explain the reason functions are favored in programming. (8 marks)
c) Write a program that will output the day of the week when a number is entered from the keyboard. (10 marks)
Examination Irregularity is punishable by expulsion Page 3 of 3
F 5519 (Pages: 2) No Name .. M.C.A (Affiliatede Colleges) Degree Examination, February 2006 First Semester Problem Solving and Computer Programming in "C"