Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
104 views5 pages

CIT 3102 Past Papers

This document outlines the examination details for first-year students at Meru University of Science and Technology, specifically for the course CIT 3102: Fundamentals of Computer Programming. It includes instructions, a series of programming questions, and tasks related to C programming concepts such as data types, decision-making structures, loops, and functions. The exam is structured into five questions, each with multiple parts, covering various programming topics and practical coding exercises.

Uploaded by

Evans Ngebe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
104 views5 pages

CIT 3102 Past Papers

This document outlines the examination details for first-year students at Meru University of Science and Technology, specifically for the course CIT 3102: Fundamentals of Computer Programming. It includes instructions, a series of programming questions, and tasks related to C programming concepts such as data types, decision-making structures, loops, and functions. The exam is structured into five questions, each with multiple parts, covering various programming topics and practical coding exercises.

Uploaded by

Evans Ngebe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

MERU UNIVERSITY OF SCIENCE AND TECHNOLOGY

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


Tel: +254(0) 799 529 958, +254(0) 799 529 959, + 254 (0) 712 524 293,
Website: [email protected] Email: [email protected]

University Examinations 2018/2019

FIRST YEAR FIRST SEMESTER EXAMINATION FOR THE DEGREE OF BACHELOR


OF SCIENCE IN COMPUTER SCIENCE, BACHELOR OF COMPUTER TECHNOLOGY,
BACHELOR OF INFORMATION TECHNOLOGY, BACHELOR OF SCIENCE IN
COMPUTER SECURITY AND FORENSICS, BACHELOR OF SCIENCE IN ACTURIAL
SCIENCE, BACHELOR OF SCIENCE IN STATISTICS, BACHELOR OF SCIENCE IN
MATHEMATICS AND COMPUTER, BACHEOR OF SCIENCE IN PHYSICAL SCIENCE
AND BACHELOR OF SCIENCE IN EDUCATION

CIT 3102: FUNDAMENTALS OF COMPUTER PROGRAMMING

DATE: JANUARY 2019 TIME: 2 HOURS

INSTRUCTIONS: Answer question one and any other two questions

QUESTION ONE (30 MARKS)

a) Define each of the following terms as used in programming (4 marks)

i. Programming

ii. Assembler

iii. Interpreter

iv. Compiler

b) Citing appropriate examples, describe the two main high level languages programming
paradigms (4 marks)

c) Describe the difference in the meaning of the 5 in int x[5]; and the meaning of the 4 in
x[4]. What are the meaning of the [5] and the [4] (4 marks)

d) Enumerate any six C built-in data types (3 marks)

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


Foundation of Innovations Page 1
e) Outline any four restrictions that must be observed when declaring variables in C

(4 marks)

f) Consider the following program.

#include<stdio.h>

Int main (void)

INT sum;

/*COMPUTE RESULT

Sum=25+37-19

/*DISPLAY RESULT//

Printf (“The answer is% i/n”sum);

Return 0;

i. Identify the syntactic errors in the following program (4 marks)

ii. Rewrite the corrected program (3 marks)

g) Distinguish between each of the following pair of words in programming

i. Recursion and interation

ii. Syntax and semantic error

QUESTION TWO (20 MARKS)

a) With appropriate examples, describe any two decision making and two looping
structures (4 marks)

b) Write the algorithm pseudo code to be followed by a program that reverse can integer
number entered by the user (e.g if the user enters 10591, the program outputs 19501)
(4 marks)

i. Write a C program to implement the above algorithm (6 marks)

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


Foundation of Innovations Page 2
c) Design a C program to input employees name, hours worked and rate per hour
calculate the basic pay=hours worked* rate per hour, tax is charged according to basic
pay. If basic pay is greater than 20000, a tax of 10% of basic pay is charged, otherwise
a tax 5%is charged. Net salary = basic – tax. The program should display employee
name, basic salary, tax and net salary (6 marks)

QUESTION THREE (20 MARKS)


a) Write the syntax of a DO....WHILE loop, hence explain how it differs with a WHILE
loop (4 marks)
b) Explain two rules used when declaring variables (2 marks)
c) Using SWITCH decision making statement, write a C code that prompts a user to enter
two integers. The code then prompts a user to select from options 1-3 inclusively. If a
user selects option 1 the code returns the sum of the two integers, if the user selects
option 2 returns the product of the numbers; if the user selects option 3 it returns the
sum of the squares of the numbers (6 marks)
d) Figure below show standard playground shapes of various institutions. Use it to answer
a question that follows:

Using a function for each of the parts labelled X,Y and Z. Write C program to assist
the institutions in calculating the total of painting their playgrounds, if 1m2 is painted
using ksh 150 and a user is to enter distances, a,b and c of their institution in meters.
Take pie to be 3.14 (8 marks)

QUESTION FOUR (20 MARKS)


a) Write a program to enter dimension of a triangle then use a function to calculate area
of a triangle and return the result (5 marks)
b) Use an example to illustrate the difference between local and global variables
(4 marks)

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


Foundation of Innovations Page 3
c) In a certain restaurant, a waiter requires one tray to carry three served plates. Write a C
code that prompts a waiter to enter the number of served plates to carry, hence it
calculate and prints the number of trays to use. Assuming all the served plates are to be
delivered at the same time, and no half tray. (hint:4 served plates require 2 trays to
carry and not 1.33 trays as in ordinary calculations) (5 marks)
d) Write a C code to display the factors of a positive integer entered by a user. (factors are
numbers that are divisible by the entered integer. They should be between 1 and that
integer inclusively) (6 marks)

QUESTION FIVE (20 MARKS)


a) Consider the following program to answer the questions that follow;
// program to determine tomorrow’s date
#include <stdio.h>
int main (void)
{
struct date
{
int month;
int day;
int year;
};
struct date today, tomorrow
const int days perMonth[12]={31,28,31,30,31,30,31,31,30,31,30,31};
printf(“Enter today’s date(mm dd yyyy):”);
scanf(“%i%i%i”, &today.month,&today.day,&today.year);
if(today.day!=day!=daysPer Month[today.month-1]){
tomorrow.day = today.day+1;
tomorrow.month = today.month
tomorrow.year = today.year;
}
else if(today.month = = 12){// end of year
tomorrow.day = 1;

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


Foundation of Innovations Page 4
tomorrow.month = 1;
tomorrow.year =today.year + 1;
}
else {// end of month
tomorrow.day = 1;
tomorrow.month = today.month + 1;
tomorrow.year = today.year;
}
printf(“tomorrow’s date is %i%i%2i./n”,tomorrow.month,tomorrow.day,
tomorrow.year%100);
return 0;
}
i. What is the name of the structure data type in this program? (2 marks)
ii. Enumerate the two structure variables that have been declared in the program
(2 marks)
iii. Unlike primitive data type variables, a special syntax is needed when dealing with
structure variables. Explain using an example from the program (4 marks)
iv. Write the expected output when each of the following is passed;
a) 2 28 2000 (2 marks)
b) 12 17 2014 (1 mark)
c) 12 31 2016 (1 mark)
v. When the date entered is 2 28 2004 the program outputs
Tomorrow’s date is 3/1/04
Explain why this happens (2 marks)
vi. Write a function to fix the above problem (6 marks)

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


Foundation of Innovations Page 5

You might also like