Get premium membership and access revision papers, questions with answers as well as video lessons.
Got a question or eager to learn? Discover limitless learning on WhatsApp now - Start Now!

Introduction To Computer Programming Question Paper

Introduction To Computer Programming 

Course:Bachelor Of Technology In Civil Engineering

Institution: Masinde Muliro University Of Science And Technology question papers

Exam Year:2016



MASINDE MULIRO UNIVERSITY OF SCIENCE AND TECHNOLOGY (MMUST)
UNIVERSITY EXAMINATIONS
2016/2017 ACADEMIC YEAR
SECOND YEAR FIRST SEMESTER EXAMINATIONS
For the Degree of
BACHELOR OF TECHNOLOGY IN CIVIL, ELECTRICAL, AND MECHANICAL ENGINEERING
COURSE CODE: CSC 201
COURSE TITLE: INTRODUCTION TO COMPUTER PROGRAMMING

Instructions to candidates:
answer QUESTION ONE and ANY other TWO QUESTIONS.
Time: 2Huors

QUESTION ONE
a)Explain the following terms as used in C programming (2mrks)
variable
array
b)using flow charts outline FOR and DO...WHILE iteration constructs. Using code excerpts, explain how they are implemented in C.(4mrks)
c) state and explain THREE types of errors commonly made by programmers. (3mrks)
d) explain the difference between the following concepts (2mrks)
source code and object code
high level language and machine language
e) Two gears are rotating clockwise in order to move a machine. the larger gear has a radius of 50 mm and the smaller gear has a radius 25mm. the larger gear rotates the smaller gear, and the smaller one in turn moves the machine 1M every time it rotates. using a C code excerpt, show the distance covered after the larger gear has rotated 5 times. (5mrks)

f) Explain the precedence rules of arithmetic operators. (2mrk)
g) evaluate the following expressions on the basis of operator precedence rules explained in f above.(a=5,b=4 and c=2) (3mrks)
a+b++*11/(8-c)
17.5/c-21%--a
13-4/c*++c+(17%b++)
h) write c code segment that will read values from the keyboard and store them in the variables declared as shown below. (3mrks)
int length;
float tension;
char gender;
i) write c statement that outputs a value of type float stored in a variable tax in a field six characters wide with 3 digits after the decimal point. (2mrks)
j) using a recursive function, write a program that calculates the GCD of two integers. (4mrks)

QUESTION TWO
a) explain what does the line #include do for your program (2mrks)
b) with the help of examples, explain two types of comments in c programming language. (4mrks)
c) using a loop construct of your choice, write a code excerpt that will give the output below. (4mrks)
*
**
***
****
*****
******
******
*****
****
***
**
*
d) rewrite the following while loop as a for loop. (4mrks)
int i=1;
while(i<=10){
if(i<8&&i!=2||i%4!=0)
printf("%d",i--);
i++
}
e) write the output of the code in d above. (2mrks)
f) state ANY FOUR rules that must be observed by variable names. (2mrks)
g) using illustrations differentiate a pointer and a linked-list. (2mrks)

QUESTION THREE
a) what is a function? (2mrks)
b) using while loop write a c program that calculates factorials of a non negative integer. (4mrks)
c) 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. (5mrks)
d) write the output of the c code segment below. (3mrks)
int x=2;
int sum=3++;
sum-=x++;
sum+=x;
sum*=++x;
printf("%d",x);
printf("%d",sum);
e) state and explain any THREE benefits of functions. (6mrks)

QUESTION FOUR
a) using examples differentiate a symbolic constant and literal constant in C. (4mrks)
b) what is the output of the C code excerpt below? explain your answer. (4mrks)
int a=9;
int b=7+a++;
if(a b=++a;
a*=3;
printf("%d",a);
}
else if(a%3!=0){
printf("%d",a);
}
else{
int c=--a+b;
printf("%d", c);
c) using examples differentiate between function prototypes and function definition. (4mrks)
d) write a c program with function named average. this function returns mean of four variables;a,b,c,d all of type int as a float. test this function using any four integers from user and display the mean in the main function. 4mrks
e) explain ANY FOUR advantages of modular programming. (4mrks)

QUESTION FIVE
a) explain what is an algorithm. (2mrks)
b) explain the difference between a statement and an expression as used in C. (2Mrks)
c) write C program that displays marks of ten students in five subjects. marks are stored in a two dimension array called marks. display sum and average of each student. (5mrks)
d) an array is declared as matrix[4][5];
i. how many elements can be stored in this array? (1mrk)
ii. what is the reference of the second element in the array? (1mrk)
iii. what is the reference to the last element in the array? (1mrk)
vi. write a c statement that initializes the fourth element in the array with the value four. (1mrk)
e) write a recursive function that calculates the factorials of non negative integer.(4mrks)
f) rewrite the function in e above to use a for loop to calculate factorial of a non negative number. (3mrks)






More Question Papers


Popular Exams



Return to Question Papers