Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Flowcharts Lesson With Answers

Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

Page 1 of 18

YAMISHI TUITION CENTRE


LESSON ON FLOW CHARTS
Introduction
 Intelligence is a mental quality that consists of the abilities to learn from experience,
adapt to new situations, understand and handle abstract concepts, and use knowledge
to manipulate one's environment.
 Intelligence is one of the key characteristics which differentiates a human being from
other living creatures on the earth.
 Basic intelligence covers day to day problem solving and making strategies to handle
different situations which keep arising in day to day life.
DEFINITIONS
PSEUDO CODE
 A pseudo code is a set of statements written in a human readable language (usually
English – like phrases) but expressing the processing logic of a program.
 A pseudo code is an artificial and informal language that helps programmers develop
algorithms
GUIDELINES FOR DESIGNING A GOOD PSEUDO CODE
1. The statement must be short, clear and readable.
2. The statement must not have more than one meaning, i.e., should not be ambiguous.
3. The pseudo code lines should be clearly outlined and indented.
4. A pseudo code should show clearly the start and the stop of executable statements and
the control structures.
5. The input, output and processing statements should be clearly stated, using keywords
such as PRINT, READ, INPUT etc.

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.

Yamishi Lawrence Yamishi Tuition Centre 2018/GCE


Page 2 of 18

 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.

FLOW CHART SYMBOLS


 There are 6 basic symbols commonly used in flow charting of assembly language
Programs: Terminal, Process, input, Decision, Flow lines and output.
 This is not a complete list of all the possible flow charting symbols, it is the ones used
most often in the structure of assembly language programming

Yamishi Lawrence Yamishi Tuition Centre 2018/GCE


Page 3 of 18

ELEMENTS OF A FLOW CHART


 Various geometrical shaped boxes represent the steps of the solution.
 The boxes are connected by directional arrows to show the flow of the solution.

FLOW CHART OPERATIONS


1. ‘+’ for Addition
2. ‘-’ for Subtraction
3. ‘*’ for Multiplication
4. ‘/’ for Division and
5. ‘ ’ for assignment.
For example A X*3 means A will have a value of X*3.
ALGORITHMS AND FLOW CHARTS
 A typical programming task can be divided into two phases:
o problem solving phase
o produce an ordered sequence of steps that describe solution of problem
 This sequence of steps is called an algorithm
 Implementation phase
o Implement the program in some programming language
PSEUDOCODE & ALGORITHM
Example 1:
Write an algorithm to determine a student’s final grade and indicate whether it is passing or
failing. The final grade is calculated as the average of four marks.

Yamishi Lawrence Yamishi Tuition Centre 2018/GCE


Page 4 of 18

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.

Yamishi Lawrence Yamishi Tuition Centre 2018/GCE


Page 5 of 18

(2). THE “IF … THEN … ELSE STATEMENT”


The “IF … THEN … STATEMENT” is used when only two (2) options are available.
Its structure is as shown below:

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.

Yamishi Lawrence Yamishi Tuition Centre 2018/GCE


Page 6 of 18

(3) THE “NESTED IF STATEMENT”


The “NESTED IF STATEMENT” is used when more than two options are available.
Its structure is as shown 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

Yamishi Lawrence Yamishi Tuition Centre 2018/GCE


Page 7 of 18

Answer

Yamishi Lawrence Yamishi Tuition Centre 2018/GCE


Page 8 of 18

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

Else Volume= π ∗ square radius ∗ height


End if
Display volume
Stop
Draw the corresponding flowchart for the information given above.

Yamishi Lawrence Yamishi Tuition Centre 2018/GCE


Page 9 of 18

Answer

Yamishi Lawrence Yamishi Tuition Centre 2018/GCE


Page 10 of 18

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.

Yamishi Lawrence Yamishi Tuition Centre 2018/GCE


Page 11 of 18

ACTIVITY 5 (OCTOBER 2016 PAPER 1 QUESTION 17b)


In the answer space below, is an incomplete simple program pseudo code for calculating and
outputting the volume of a cylinder 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.
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.

Complete the table in the answer space below.


Income Tax
K2 900.00
K5 000.00

Yamishi Lawrence Yamishi Tuition Centre 2018/GCE


Page 12 of 18

ACTIVITY 7 (JULY 2017 GCE PAPER 2 QUESTION 6b)


The program below is given in the form of a flow chart.

Write a pseudo code corresponding to the flow chart program above.


ACTIVITY 8 (NOVEMBER 2017 G12 REGULAR PAPER 1 QUESTION 20b)
The diagram below is an incomplete program flow chart to calculate the curved surface area,
S, of a cone with base radius r and slant height l. Complete the flow chart below by writing
appropriate statements in the blank symbols.

Yamishi Lawrence Yamishi Tuition Centre 2018/GCE


Page 13 of 18

ACTIVITY 9 (NOVEMBER 2017 G12 REGULAR PAPER 2 QUESTION 6)


Study the flow chart below.

Write the pseudo code corresponding to the flow chart program above.

Yamishi Lawrence Yamishi Tuition Centre 2018/GCE


Page 14 of 18

EXPECTED ANSWERS
ACTIVITY 1

ACTIVITY 2

Yamishi Lawrence Yamishi Tuition Centre 2018/GCE


Page 15 of 18

ACTIVITY 3

ACTIVITY 3

Yamishi Lawrence Yamishi Tuition Centre 2018/GCE


Page 16 of 18

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

Yamishi Lawrence Yamishi Tuition Centre 2018/GCE


Page 17 of 18

ACTIVITY 7 (JULY 2017 GCE PAPER 2 QUESTION 6b)

ACTIVITY 8 (NOVEMBER 2017 G12 REGULAR PAPER 1 QUESTION 20b)

Yamishi Lawrence Yamishi Tuition Centre 2018/GCE


Page 18 of 18

ACTIVITY 9 (NOVEMBER 2017 G12 REGULAR PAPER 2 QUESTION 6)

PREPARED AND PRESENTED BY


MR. YAMISHI LAWRENCE
MPIKA BOYS’ SECONDARY SCHOOL
P.O. BOX 450142,
MPIKA – MUCHINGA
ZAMBIA
yamishi777@gmail.com and yamishi@yahoo.com
0955 – 960420
0965 – 742446
0973 – 060296

@ 2018 PRODUCTION

Yamishi Lawrence Yamishi Tuition Centre 2018/GCE

You might also like