BIT 113 FUNDAMENTALS OF PROGRAMMING
BIT 113
FUNDAMENTALS OF PROGRAMMING
QUESTION ONE (30 MARKS)
a)
Distinguish
between object code and source code (2
marks)
b)
State any
two functions of language translators. (2
marks)
c)
Analyze the
following problems by dividing them into input and storage. processing and
output (6 marks)
i.
Write a
program to accept four numbers and return and output their sum, average, and
product.
ii.
Persons under
18 are not allowed to vote. Write a program to read a person’s age and if it is
under 18, and output ‘Underage person’
iii.
Write a
program to compute the sum of natural numbers from 1 to 10.
d)
Write a C
program instruction to output ‘Warning: Read all labels before washing‘. (2
marks)
e)
Write a C
program instruction to input the price of a textbook and the percentage
discount given. (2 marks)
f)
State any
two characteristics of C Language (2 marks)
g)
Using flowchart
extract explain the differences between while loop and do while loop. (4 marks)
h)
A carpenter
is paid a contract fee of Kshs15000.00 for 3 days work. He hires 3 workers who
work for 3 days each at Kshs. 350 a day. Design a pseudocode and a flowchart to
calculate and print the amount of money paid to each worker, the total paid to
all the workers and the amount the carpenter is left with. (10
marks)
QUESTION TWO (20 MARKS)
a)
Define the
term operator as used in programming and identify any two types of operators. (2
marks)
b)
Using flowchart
constructs, explain the differences between if and if … else statements. (6 marks)
c)
Explain the
difference between actual and formal parameters. (2 marks)
d)
A club
plays football only on Sundays and only if it is not raining. Write a C program
that read the day and the weather and output ‘Game on’ if the weather is good
and the day is Sunday. or’ Play suspended' if it is Sunday and it is raining. (10 marks)
QUESTION THREE (20 MARKS)
a)
By using
valid example, write down the syntax of a variable definition in C. (2 marks)
b)
Assume variable
A holds 10 and variable B holds 20, what is? (3 marks)
i.
B%A
ii.
A++
iii.
B--
c)
Explain the
difference between variable declaration and variable definition. (2 marks)
d)
Write a C
program to print your name. date of birth and mobile number. (3 marks)
E.
pecked Output:
Name
: Jane Malowa DOB : July 14, 2001
Mobile
: 0722334466
e)
Write a C
program that accepts integer numbers from a user until a user enters sentinel
value of 0 and prints the sum of all the positive numbers entered and the sum
of all negative numbers entered. The number of positives and negatives must
also be printed. (10
marks)
QUESTION FOUR (20 MARKS)
a)
Using a
valid example, discuss the usage of a switch statement. (4 marks)
b)
Define the
term pre-processor as used in C programming and I ist any three examples of
pre-processors in C language.
(4 marks)
c)
Explain the
benefits of using arrays in programming. (2
marks)
d)
Write a C
program that stores 10 integers given by users in a one dimensional array. The program
should display the largest and the smallest numbers of the array. (10 marks)
QUESTION FIVE (20 MARKS)
a)
Compare and
contrast local and global variables. (4
marks)
b)
Explain how
global variables are declared. (2 marks)
c)
i.
Write the
general form of a C function definition. (2 marks)
ii.
Explain the
main parts of a function (2 marks)
d)
Write a
function named biggest that receives three integer arguments and returns the
largest of the three values. (10 marks)
- Studocu (C - Basic Introduction)
Comments
Post a Comment