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

CIT-3102-FUNDAMENTALS-OF-COMPUTER-PROGRAMMING-1

The document outlines the examination details for various Bachelor of Science programs at Meru University of Science and Technology for the course CIT 3102: Fundamentals of Computer Programming. It includes instructions for the exam, a variety of questions covering programming concepts, algorithms, and C programming tasks. The examination is scheduled for January 2022 and consists of multiple questions requiring both theoretical explanations and practical programming solutions.

Uploaded by

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

CIT-3102-FUNDAMENTALS-OF-COMPUTER-PROGRAMMING-1

The document outlines the examination details for various Bachelor of Science programs at Meru University of Science and Technology for the course CIT 3102: Fundamentals of Computer Programming. It includes instructions for the exam, a variety of questions covering programming concepts, algorithms, and C programming tasks. The examination is scheduled for January 2022 and consists of multiple questions requiring both theoretical explanations and practical programming solutions.

Uploaded by

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

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: www.must.ac.ke Email: [email protected]

UNIVERSITY EXAMINATIONS 2021/2022

FIRST YEAR, FIRST SEMESTER EXAMINATION FOR DEGREE OF BACHELOR OF


SCIENCE IN MATHEMATICS AND COMPUTER SCIENCE, BACHELOR OF SCIENCE
IN DATA SCIENCE, BACHELOR OF SCIENCE IN COMPUTER TECHNOLOGY,
BACHELOR OF SCIENCE IN COMPUTER SECURITY AND FORENSIC, BACHELOR
OF SCIENCE IN MATHEMATICS AND COMPUTER SCIENCE, BACHELOR OF
SCIENCE IN STATISTICS, BACHELOR OF SCIENCE IN SYSTEM MANAGEMENT,
BACHELOR OF SCIENCE IN ACTURIAL SCIENCE, BACHELOR OF SCIENCE IN
BUSINESS INFORMATION TECHNOLOGY, BACHELOR OF SCIENCE IN
INFORMATION SCIENCE, BACHELOR OF EDUCATION ARTS, BACHELOR OF
SCIENCE IN EDUCATION SCIENCE AND BACHELOR OF SCIENCE IN BUSINESS
INFORMATION TECHNOLOGY

CIT 3102: FUNDAMENTALS OF COMPUTER PROGRAMMING

DATE: JANUARY 2022 TIME: 2 HOURS

INSTRUCTIONS: Answer Question ONE and any other TWO questions.

QUESTION ONE (30 MARKS)

a) Differentiate between a flowchart and pseudocode (4 Marks)


b) List and explain any four attributes of a good algorithm (4 Marks)
c) Differentiate between a local variable and a global variable (4 Marks)
d) Using a suitable example, illustrate the structure of a two-dimensional array. (4 Marks)
e) Give two differences between the while-do and do- while control structures. as used in
computer programming (4 Marks)
f) Using an example in each case, explain two ways of declaring constants in C
(4 Marks)
g) Differentiate declaration and definition in programming. Write the syntax for function
declaration and definition (4 Marks)
h) Differentiate between a compound statement and simple statement. (2 Marks)

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


Foundation of Innovations Page 1
QUESTION TWO (20 MARKS)

a) Using a SWITCH statement, write a C program that prompts a user to enter two integers.
The program 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 it returns
the product of the numbers; if the user selects option 3 it returns the sum of the squares of
the numbers (5 Marks)
b) Write a C program, using a WHILE LOOP, to print the sum of all odd integer numbers
between 1 and 20. (5 Marks)
c) Describe the various stages of a software development life cycle (5 Marks)
d) Write a function to calculate and return the factorial of a number supplied to the function
as a parameter. (5 Marks)

QUESTION THREE (20 MARKS)

a) Design a flow chart for a solution to a problem of calculating the average of a set of n (user
specified) numbers. (6 Marks)
b) Write a C program to accept two integers, determines and display the largest among them
on the screen. (5 Marks)
c) Outline the five rules that should be followed when declaring variables in C.
(5 Marks)
d) Using an example, explain the following terms as used in C programming. (4 Marks)
i) Type casting
ii) Dry running

QUESTION FOUR (20 MARKS)

a) The following code fragment is a pseudocode used to solve a problem.


1. Declare variables x, y, z, and result of type int (in separate statements)
2. Prompt the user to enter three integers
3. Read three integers from the keyboard and store them in the variables x, y
and z
4. Compute the product of the three integers contained in variables x, y and z
and assign the result to the variable result.
5. Print “the product is” followed by the value of the variable result.

i) Write a program to implement the above pseudocode (5 Marks)

ii) Use a flowchart to implement the fragment in (i) above (4 Marks)

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


Foundation of Innovations Page 2
b) Explain any three advantages of using functions in a program. (6 Marks)

c) Study the program code below, then identify the errors, and rewrite the correct program
code without the errors. (5 Marks)

#include <stdio.>
void main()
{
int a, b, sum, product
double 8average;
printf("Enter a value for a\n”);
scanf(“%d”,a);
printf("Enter a value for b\n);
scanf(“%d”,&c);
sum = a + b;
product=a*b;
8average = (double) sum/2;
printf(“\n%d+%d=%d”,num1,num2,sum);
printf("The average is %4.2lf\n”);
return 0;
)

QUESTION FIVE (20 MARKS)

a) Write the output of the following code (5 Marks)


#include <stdio.h>
int main ()
{
int i, j;
for(i=50; i<75; i++) {
for(j=2; j<=(i/j); j++)
if(!(i%j)) break; // if factor found, not prime
if(j > (i/j)) printf("%d is prime\n", i);
}
return 0;
}

b) Write a C program that output values that are divisible by 3 in descending order, between 1
and 100 (5 Marks)
c) Watoto CBC class has 15 pupils, who learn 3 subjects (Maths, English, and Drawing)
each. Using arrays, write a code that will enable their teacher capture the marks of all the
students and display the marks and totals for each student. (each student marks should be
in its own line, separated by a tab space placed under the subject title). (6 Marks)
d) Use examples to describe two ways of representing comments in C programming.
(4 Marks)

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


Foundation of Innovations Page 3

You might also like