0% found this document useful (0 votes)
133 views2 pages

CIT 3102 Programming Supp Town

The document contains 5 questions regarding fundamentals of computer programming in C. It asks questions about local vs global variables, debugging vs testing, high vs low level languages, writing a program to calculate depreciation using a straight line method, using comments in C programs, developing an algorithm and program to calculate employee pay based on hours worked and overtime, defining variables and naming conventions, using a SELECT CASE statement, correcting errors in a sample program, defining functions and writing a function to calculate the sum of two numbers, differences between compilers and interpreters, variable declaration, the for loop, writing a program to calculate the square and cube of a number, steps in problem solving, designing a flowchart to calculate average of numbers, analyzing sample

Uploaded by

zareebrawny
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)
133 views2 pages

CIT 3102 Programming Supp Town

The document contains 5 questions regarding fundamentals of computer programming in C. It asks questions about local vs global variables, debugging vs testing, high vs low level languages, writing a program to calculate depreciation using a straight line method, using comments in C programs, developing an algorithm and program to calculate employee pay based on hours worked and overtime, defining variables and naming conventions, using a SELECT CASE statement, correcting errors in a sample program, defining functions and writing a function to calculate the sum of two numbers, differences between compilers and interpreters, variable declaration, the for loop, writing a program to calculate the square and cube of a number, steps in problem solving, designing a flowchart to calculate average of numbers, analyzing sample

Uploaded by

zareebrawny
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/ 2

MERU UNIVERSITY OF SCIENCE AND TECHNOLGY

CIT 3102 FUNDAMENTALS OF COMPUTER PROGRAMMING


BACHELOR OF SCIENCE INFORMATION TECHNOLOGY
Question ONE (30 marks)
a) Differentiate between: (6 marks)
i. A local variable and a global variable
ii. Debugging and testing
iii. A high level language and a low level language
b) The straight line method of computing the yearly depreciation of the value of an item is given by:
Depreciation = Purchase – Salvage Value
Year of Service
Write a C program to determine Depreciation Value of an item when the purchase price, Year of service
and the annual depreciation are given [5 marks]

c) State the role of comments in programming and discuss the two ways in which comments are
represented in a C program. (5 Marks)
d) A solution is required that requests the user for the overtime hours worked by an employee and
the advance pay taken by an employee during the month the solution then determines the pay of
the employee based on the following guidelines: basic pay ksh 47,500 per month, overtime
allowance of ksh 1,000 per hour. Required:
i. Devise an algorithm to solve the problem (5 Marks)
ii. Write a C program to solve the problem (5 Marks)
e) Define the term variable and discuss any THREE rules guiding the naming of variables.
(4 Marks)
Question TWO (20 marks)
a) Using a SELECT CASE statement write a program in C that allows a user to key in a number between 1
and 8; the program then outputs the number in words.
(6 Marks)
b) Identify and correct the errors in the following program. After corrections, what output would it
produce when executed? (5 Marks)
#include<stdio.h>
void main()
{ Float pi = 3.142;
float radius, c, a;
r = 7;
c = pi * 2 * r;
a = pi * r * r;
printf("The area is %f", a);
printf("\nThe circumference is %f", c)
c) Discuss the role of functions in a C program and write the syntax for defining a function.
(4 Marks)
d) Write a C program to input two numbers then use a user defined function to calculate the sum of
the two numbers entered and display the result. (5 marks)
Question THREE (20 marks)
a) Discuss any THREE differences between a compiler and an interpreter. (6 Marks)
b) Discuss the role of variable declaration in programming and write an example statement that
declares a variable. (4 Marks)
c) Write the syntax and discuss the parts that make up the for loop. (5 Marks)
d) Write a C program that accepts a user input number and computes and displays the square and
the cube of the number. (5 Marks)
Question FOUR (20 marks)
a) Discuss the steps followed by a programmer as he/she develops a solution to a problem.(6 Mks)
c) Design a flow chart for a solution that calculates the average of a set of N(user specified)
numbers. (5 Marks)
d) Write the output of the following sections of code [4 Marks]
Int x[5]={5,2,7,5,8}
C,count=0;
For (c=0; c<5; c++)
If (x[c]>5)
Count++;
Printf (“%d”,count);
e) Design a C program to input employee name, hours worked and rate per hour then 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 of 5% is charged. Net
salary = basic – tax. The program should display employee name, basic salary, tax and net salary.
(5 marks)
Question FIVE (20 marks)
a) Write a program in C that accepts a user input number and checks if the number is even or odd;
the program then outputs the appropriate message. The program should allow the user to repeat
the process five times. (5 Marks)
b) Write a program using C to print the triangle of asterisks shown below [5 Marks]
*
**
***
****
*****
c) Write a program in C that accepts ten user input cat marks, stores them in an array and calculates
and display the average cat mark. (6 Marks)
d) State the name, discuss the role and cite an example usage of the operator: % in programming.
(4 Marks)

You might also like