Flowcharts Lesson With Answers
Flowcharts Lesson With Answers
Flowcharts Lesson With Answers
ALGORITHM
An algorithm is a set of operations that produce a result. It describes precisely what
must be done with an input to get an output and end the process.
An input is information that is needed to solve a problem.
An output is the result of a calculation.
Each shape represents one step in the process. The arrows show the order of the steps
in the algorithm.
o An action is written in the rectangle.
o An input is written in the parallelogram.
o A question or information that leads to a decision is written in the diamond.
Sometimes the decision box results in a loop back to the previous step.
FLOW CHART
A flow chart is a schematic representation of a sequence of operations, as in a
manufacturing process or computer program. (Dictionary)
A flow chart is a graphical representation of the sequence of operations in an
information system or program. (Technical)
o Information system flowcharts show how data flows from source documents
through the computer to final distribution to users.
o Program flowcharts show the sequence of instructions in a single program or
subroutine.
A flow chart is a picture (graphical representation) of the problem solving process.
A flow chart gives a step-by-step procedure for solution of a problem.
A flow chart shows the steps in a process. It consists of boxes (rectangles), diamonds
(rhombi), parallelograms and other shapes that are connected with arrows.
A flow chart is drawn according to defined rules.
Similarly when you have a problem to solve using computer or in other words you
need to write a computer program for a problem then it will be good to draw a flow
chart prior to writing a computer program.
Different symbols are used to draw each type of flow chart.
Answer
Pseudo code:
o Input a set of 4 marks
o Calculate their average by summing and dividing by 4
o if average is below 50
o Print “FAIL”
o else
o Print “PASS”
IF STATEMENT
There are three (3) forms of the “IF STATEMENT”.
(1). THE IF … THEN STATEMENT
The “IF … THEN STATEMENT” is used when only one (1) option is available.
Its structure is as shown below:
EXAMPLE 1
Write the pseudo code and draw a flow chart for a program that determines if a person is
allowed to vote or not, given that a person can only vote if he/she is over 18 years old.
EXAMPLE 2
Write the pseudo code and draw the flow chart for a program that displays pass when the
mark is greater than 40 and fail when the mark is 40 or below.
EXAMPLE 3
Write the pseudo code and draw the flow chart for a program that would categorize student’s
performance in Mathematics as follows:
80 and above: Excellent
60 – 79: Good
40 – 59: Fair
0 – 39: Poor
Answer
EXAMPLE 4
In the answer space below, is an incomplete simple program pseudocode for calculating and
outputting the volume of a cone V, given the base radius r and the height h. Complete the
program by filling in the blank spaces with appropriate statements.
Begin
Enter .……………………….;
V =……………………..;
Output V;
End.
Answer
Begin
Enter ; r, h
1
V = 3 ∗ π ∗ r ∗ r ∗ h;
Output V;
End.
EXAMPLE 5
The program below is given in the form of a pseudo code.
Start
Enter radius
If radius < 0
Then display “error message” and re – enter positive radius
Else enter height
If height < 0
Then display “error message” and re – enter positive height
Answer
ACTIVITY 1
Write the pseudo code and draw a flow chart for a program that determines if a person is
allowed to obtain a National Registration Card (NRC) or not, given that a person can only
obtain a National Registration Card (NRC) if he/she is over 16 years old.
ACTIVITY 2
Write the pseudo code and draw the flowchart for a program that displays married when the
age is greater than 35 and single when the age is 35 or below.
ACTIVITY 3
Write the pseudo code and draw the flow chart for a program that would categorize student’s
performance in Mathematics as follow:
70 and above: Distinction
60 – 69: Merit
50 – 59: Credit
40 – 49: Satisfactory
0 – 39 : Unsatisfactory
ACTIVITY 4 (OCTOBER 2016 PAPER 2 QUESTION 3a)
The program below is given in the form of a pseudo code.
Start
Enter radius
If radius < 0
Then display “error message” and re – enter positive radius
Else enter height
If height < 0
Then display “error message” and re – enter positive height
1
Else Volume= 3 ∗ π ∗ square radius ∗ height
End if
Display volume
Stop
Draw the corresponding flowchart for the information given above.
V =……………………..;
Output V;
End.
ACTIVITY 6 (JULY GCE 2017 PAPER 1 QUESTION 16b)
The diagram below shows a flow chart for a program to calculate tax on an income.
Write the pseudo code corresponding to the flow chart program above.
EXPECTED ANSWERS
ACTIVITY 1
ACTIVITY 2
ACTIVITY 3
ACTIVITY 3
ACTIVITY 4
ACTIVITY 5
Begin
Enter ; r, h
V = π ∗ r ∗ r ∗ h;
Output V;
End.
ACTIVITY 6 (JULY GCE 2017 PAPER 1 QUESTION 16b)
Tax = 0.3 * (K5 000.00 –K3 000.00)
Tax = 0.3 * K2 000.00
Tax = 3 * K200.00
Tax = K600.00
Income Tax
K2 900.00 K0.00
K5 000.00 K600.00
@ 2018 PRODUCTION