0% found this document useful (0 votes)
47 views

Programming 2

Meru University of Science and Technology is announcing supplementary/special examinations for first year students in computer science and related degrees. The exam covers introduction to computer programming fundamentals and is divided into 5 questions. Question 1 has multiple parts testing understanding of programming languages, data types, algorithms, flowcharts, and writing basic programs. Questions 2-5 continue testing programming concepts like variables, arrays, loops, conditional statements, errors, and flow control structures. The document provides instructions and multiple choice questions to assess first year programming skills.

Uploaded by

Smasher Austine
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views

Programming 2

Meru University of Science and Technology is announcing supplementary/special examinations for first year students in computer science and related degrees. The exam covers introduction to computer programming fundamentals and is divided into 5 questions. Question 1 has multiple parts testing understanding of programming languages, data types, algorithms, flowcharts, and writing basic programs. Questions 2-5 continue testing programming concepts like variables, arrays, loops, conditional statements, errors, and flow control structures. The document provides instructions and multiple choice questions to assess first year programming skills.

Uploaded by

Smasher Austine
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

MERU UNIVERSITY OF SCIENCE AND TECHNOLOGY

P.O. Box 972-60200 – Meru-Kenya


Tel: 020-2069349, 061-2309217. 064-30320 Cell phone: +254 712524293, +254 789151411
Fax: 064-30321
Website: www.must.ac.ke Email: [email protected]

University Examinations 2014/2015

FIRST YEAR SUPPLEMENTARY/SPECIAL EXAMINATION FOR THE DEGREE


OF
BACHELOR OF SCIENCE IN COMPUTER SCIENCE/COMPUTER SECURITY AND
FORENSICS/MATHEMATICS AND COMPUTER SCIENCE/INFORMATION
TECHNOLOGY/COMPUTER TECHNOLOGY/GACHELOR OF BUSINESS
INFORMATION TECHNOLOGY

CIT 3153/CCA 3112/CIA 3112: INTRODUCTION TO COMPUTER PROGRAMMING


FUNDAMENTALS OF COMPUTER PROGRAMMING

DATE: JULY 2015 TIME: 2 HOURS


INSTRUCTIONS: Answer question one and any other two questions.

QUESTION ONE (30 MARKS)


a) State two structured programming languages other than C (2 marks)
b) Differentiate between a compiler and an interpreter (2 marks)
c) A student intended to create a program to computer the following details. Student’s
national ID, name, fees payable and the number of meals per day the student has paid for.
For each of the items state a corresponding data type (4 marks)
d) Predict the output of the following code (3 marks)
#include<stdio.h>
Main ()
{
int x=3;
{
while (x<33)
x=x+1;
}
printf(“%d”,x);
}

Meru University of Science & Technology is ISO 9001:2008 Certified


Foundation of Innovations Page 1
e) Define the term algorithm and briefly discuss any FOUR properties of an algorithm.
(5 marks)
f) Draw a program flowchart that finds the area of a circle. The program should only accept
the value radius between 7 to 70 (7 marks)
g) Figure 1 shows the playground of a certain insti9tution. Use it to answer the question
that follow:

50m
x 30m
Y z

40m
h) Using a function for each of the parts labeled X, Y and Z. Write a C program to calculate
the total area covered by the playground take pie to be 3.14 (7 marks)

QUESTION TWO (20 MARKS)

a) State two limitations of high level languages (2 marks)


b) What is the output of the following section (4 marks)
Int a,b;
For (a=0; a<3; a++)
For (b=0; b<=3;b++)
Printf(“%d”,b);
c) Define the following terms (3 marks)
(i) Identifier
(ii) Data type
(iii) Operator precedence
d) Differentiate the following terms as used in programming (4 marks)
(i) Local variable and global variable
(ii) Call by value and call by reference
e) Write a C program using a one dimensional array that reads in five values and displays
them (7 marks)

Meru University of Science & Technology is ISO 9001:2008 Certified


Foundation of Innovations Page 2
QUESTION THREE (20 MARKS)

a) Suppose x, y, z are simple Boolean expressions and all currently have the value FALSE.
How should the following expression evaluate? Show all your working (3 marks)
NOT X OR Y AND Z
b) Write the output of the following section of code (3 marks)
(i) Int x[5]= {5,2,7,5,8}
(ii) C,count=0;
(iii) For (c=0; c<5; c++)
(iv) If (x[c]>5)
(v) Count++;
(vi) Printf (“%d”,count);
c) Write a C program that accepts two integer values represented by a and b. Values
assigned to a should be equal to zero or greater than zero. Values assigned to b should be
less or equal to five. The program should ask the user to enter the values for a and b, if
the above conditions are met, the program should sum the two values i.e. a and b, divide
the sum by two and assign the results to a float variable called xmid. The program
should then display the value of xmid. (8 marks)
(i) The above programme will run with a warning, explain why? (3 marks)
(ii) Explain what should be done to remove the warning (3 marks)

QUESTION FOUR (20 MARKS)

a) State four parts of a for loop (4 marks)


b) Write the syntax for declaring a two dimensional array and give an example (4 marks)
c) State the equivalent code for the following statement, using a while loop (4 marks)

for (i = 0; i<10; i=i+1)

printf(“i is %d\n”, i);

Meru University of Science & Technology is ISO 9001:2008 Certified


Foundation of Innovations Page 3
d) The table below shows five choices and their corresponding remarks. Use it to answer
the question that follows.
Choice
1 Pilau plain
2 Githeri beef
3 Chapati chicken
4 Chips liver
5 Rice bean
All other cases No selection made
Write a C program that can be able to prompt a user to enter a choice. The program then
outputs a remark based on the choice entered. Use the switch statement. (8 marks)

QUESTION FIVE (20 MARKS)


a) State three uses for the semicolon in C programming Language (3 marks)
b) Distinguish between simple and structured data type giving an example in each case
(4 marks)
c) Using appropriate examples explain the following errors (6 marks)
(i) Syntax error
(ii) Run time Error
(iii) Logical Error
d) State the role of flow control structures in programming and discuss the two major
categories of flow control structures stating an example for each category. (7 marks)

Meru University of Science & Technology is ISO 9001:2008 Certified


Foundation of Innovations Page 4

You might also like