You are on page 1of 13

Copyright © 2009 All rights reserved

JERRY ESPERANZA
Objective
The module was designed to achieve the following;

1. Identify flowcharting symbols.


2. Use flowchart symbols in identifying steps/pseudocode in logic formulation.
3. Formulate flowchart solutions.

The material used a problem-direct solution approach. Instead of defining each


flowchart symbol first, we applied it on situation when we need it and define it on the
sidelines.

What covered on this material are program flowcharts. System flowcharts are
designed to show interface between input/output devices, to other systems, and the
program itself. It uses other specialized symbols which are beyond the coverage of this
courseware.

Though new tools are being introduced in software development, flowcharting is still
one of the effective tools in presenting the logic/idea of program execution. Students of
Computer Science or related IT courses will benefit on this courseware as one prepares
career as Scientist, Analyst, Programmer or Project Manager.

We encourage everyone to give us feedback on how you find this material so we may
improve it. You may reach us at thrivingJerry@yahoo.com. Visit also our blogsite:
http://ThrivingAndLiving.blogspot.com .

About the Author


Jerry Esperanza is a Computer Science professor. He has more than 7 years experience
teaching at Jose Rizal University (JRU) and currently at New Era University (NEU),
Philippines.

He worked as Administrative Specialist at IBM Philippines, Inc. and served as a


Technical Support Engineer at ETSI Technologies, Inc. (A Siemens Nokia joint ventured
company) for ten years. He was a Database Marketing Analyst for a year at OSRP (a
PCMall.com company) and as Analyst at Business Intelligence Group of eTelecare
Global Solutions for another couple of years.

He holds a bachelor degree in Computer Engineering at Polytechnic University of


the Philippines (PUP) and currently working on his thesis for a master’s degree in
Educational Management at New Era University Graduate Studies.

As a registered professional teacher, he believes that a teacher is behind in anyone


who excels. Continuous education is one of his advocacies to uplift human understanding
and condition.

http://ThrivingAndLiving.blogspot.com 2
Flowcharting as Algorithm Tool
Algorithm is a step-by-step procedure in solving a problem. It may be expressed in a
human language, pseudocode (not a real code), and/or with flowcharts. Flowchart is the
graphical representation of the algorithm.

Problem A gives emphasis on how to convert step-by-step tasks into a flowchart.


Terminal is mandatory symbol used in all flowcharting activities. There is only one set of
start and end terminal symbols in flowcharting an algorithm.

It is strictly enforced to use an arrow head at the end of the flow lines. It helps to
know which direction the flowchart is heading. Process box denotes action.

Problem A. Design a flowchart from the given tasks:


1. Plug in computer power cords to the Uninterruptable Power Supply
(UPS).
2. Switch on UPS.
3. Push the power-on button of the PC.
4. Enter username and password in the Microsoft XP login dialog.

Solution:
Start
Terminal symbol is
required to use at start
* and end of flowchart

Plug in computer * Flowline indicates the


power cords to the direction of the next
UPS.
instruction or sequence of
available information and
executable operation. It is
used with an arrow at the
end to denote direction.
Switch on UPS.

Push the power- Process Box represents


on button of the the process of executing
PC.
a defined or group
operations that result in
a change value, form or
location of information.
Enter username
and password in
the Microsoft XP
login dialog.

End

http://ThrivingAndLiving.blogspot.com 3
Decide which path to take
Problem B gives us a dose on how to deal with decision. The diamond symbol represents
a condition normally answered by yes or no, true or false. A path is taken and determine
the next step to do depending on the answer set by the condition.

Problem B. Design a flowchart from the given traffic procedure:


1. Slow down at intersection. 4. If signal = red
2. Check traffic light signal. 4.1 Press brake.
3. If signal = green 5. If signal = yellow
3.1 Continue driving. 5.1 Prepare to stop.

Solution 1
Start * Decision box
branches to the next
instruction depending
on the result of
condition.
Slow down at
intersection.
** On-page connector
used to direct at the next
instruction WITHIN the
page. Label it either by
letter or number or
Check traffic light
combination of both.
signal.

*
**
Signal = Y Continue driving.
green? C

Signal = Y Press brake. C


red?

Signal = Y Prepare to stop.


yellow?

N
C

End

http://ThrivingAndLiving.blogspot.com 4
Solution 2

We can solve the same problem using a different approach. No need to test if the
signal is yellow. We can logically assume that if it is not green, two conditions would
remain: either red or yellow. Green is tested first; red next. Therefore, neither green nor
red, we proceed immediately to step when the color is yellow. Thus, we eliminate the
condition of testing yellow.

Start

Slow down at
intersection.

Check traffic light


signal.

Signal = Y Continue driving.


green? C

Signal = Y Press brake. C


red?

Prepare to stop.

End

http://ThrivingAndLiving.blogspot.com 5
Initialize your Storage
Algebra uses literals (x and y variables) in solving an equation. In programming,
variables or identifiers are treated as memory storage. We need to name (and initialize) it
at the start of every program. Just like in an algebraic equation, the value of these
identifiers varies as the execution of the program progresses.

Problem C introduces the use of initialization or preparation symbol.


Parallelogram is also used specifically to signify process dedicated either to input or
output tasks.

Problem C. Design a flowchart from the given arithmetic operations:


1. Initialize x with 3; y with 4; z with 0.
2. Add x and y and store it at z.
3. If z < 10
3.1 Display “Sum is less than 10”.

Solution`

Start

Initialization or
x=3 preparation stores the
y=4 start value of identifiers
z=0 or variables at the start of
the program

z= x+y

Input/Output box
Y Display
used as an I/O
z < 10 “Sum is less function which
than 10” makes data available
for processing
N (input) or displaying
(output) of processed
End information.

http://ThrivingAndLiving.blogspot.com 6
Break Large Task into Small Tasks
We may run not just into steps but series of steps. This would be a dilemma for
programmers and analysts if they are working on larger systems. It would hard for them
to contain the problem if something goes wrong. One way to avoid this kind of situation
is to modularize inter-related tasks into one package.

Solution for Problem D shows how flowcharting approaches modularization. It


has a main program that jumps into subtasks (addNumbers/subtractNumbers) and returns
to the calling program (main) after execution.

Subtasks are smaller programs within a program. That is why it starts and ends
with terminal symbols. Instead of the START/END texts inside these terminal symbols,
the name of subtask is indicated; RETURN signals the end of the execution within
subtask and returns to the calling program.

Problem D. Design a flowchart with two modules set.


1. addNumbers. addNumbers: subtractNumbers:
2. subtractNumbers. 1.1 Initialize x and y 2.1 Initialize z with -4.
with zero. 2.2 Subract 1 to z.
1.2 Enter number and 2.3 If z < -4
store to x. 2.3.1 Add 2 to z.
1.3 Enter number and else
store to y. 2.3.2 Subract 1 to z.
1.4 Add 1 to y. 2.4. Print the value of z.
1.5 Add y to x.
1.6 Print the value of x.

Solution:

Start

* * Predefined process box


represents a named
addNumbers process consisting of one
or more operations or
program steps that are
specified elsewhere.

subtractNumbers

End

http://ThrivingAndLiving.blogspot.com 7
addNumbers
A

x=0 y= y+1
y=0

x= x+1
Accept x

Print the
Accept y value of x.

A RETURN

subtractNumbers 1

z = -4 Y
z <-4 z=z+2

N
z=z-1
z=z-1

Print the
Off-page connector is value of z.
used to direct the next
instruction located on
ANOTHER page. Label it
either by letter or number
or combination of both. RETURN

Page 1 Page 2

http://ThrivingAndLiving.blogspot.com 8
Connectors used on loops
We can see on the solution of Problem E how connectors are utilized in doing repetitive
tasks. Connectors are best applied when loops occur in the program.

Problem E. Design a flowchart from the given pseudocode:


1. Initialize identifiers start with 1; finish with 4.
2. if start < 4
2.1 Display value of start.
2.2 Add 1 to start.
2.3 if finish > 0
2.2.1 Display value of finish.
2.2.2 Subtract 1 to finish.
2.2.3 Proceed to 2.3
2.4 Store 4 to finish.
2.5 Proceed to 2.
3. Display value of start.
4. Display value of finish.
Solution
Start A

Display
value of
start = 1 finish
finish = 4

finish = finish - 1
Y Display
start < 4 value of
start

N B

Display
value of start = start + 1
finish

Display Y
value of finish> 0
start A

End
finish = 4 C

http://ThrivingAndLiving.blogspot.com 9
Common Flowcharting Error
1. Hanging process. This is a common error where the designer left process or
predefined box hanging and does not specify the next task to do. Use may use
flow lines or connectors to correct this problem.

Y
green? Y green?
Continue Continue
driving. driving.

N N

NO! YES

2. Decision box with three-outgoing branch. You may notice from other
textbooks the use of 3-outgoing branch. Because this material is used as
introduction to programming, stick with the use of 2-outgoing branch for now.
The decision box on this case is designed only to answer conditions with YES or
NO; TRUE or FALSE.

MAYBE YES YES


She loves She loves
me? me?

NO NO

NO! YES

http://ThrivingAndLiving.blogspot.com 10
3. Too many end terminal symbols. Flowchart designers who are lazy to route the
next step to END often create more than one terminal symbol. Remember always
that you are only allowed to have one set of START/END terminal symbols in a
flowchart. Again, you may correct this error by using flow lines or connectors.

Signal = Y Signal = Y
Continue Continue
green? green?
driving. driving.

End A

N N

Signal = Y Signal = Y
Press brake. Press brake.
red? red?

N
N
A

End End

NO! YES

http://ThrivingAndLiving.blogspot.com 11
Problem Exercises
I. Design a flowchart based from the given tasks.

Problem A. 1. Initialize x and y with value 0.


2. Store 10 to x.
3. Store -3 to y.
4. if y<x
4.1 Display “x is greater than y”
4.2 Display value of x.
5. Display value of y.

Problem B. 1. Initialize age with a value of 0.


2. Accept age.
3. if age<18
3.1 Print “Minor: you cannot vote”.
4. if age >= 18
4.1 Print “Your age is eligible to vote.”
5. if age >= 65
5.1 Print “Senior Citizen: Vote wisely. Our future is at stake.”

Problem C. 1. Initialize num with value 0.


2. Display “Enter a number”.
3. Accept num.
4. if num>0
4.1 Display “Number is positive”.
else
4.2 if num<0
4.2.1 Display “Number is negative”.
else
4.2.2 Display “Number is origin”.
5. Display value of num.

Problem D. 1. Initialize inputGrade and grade with value 0.


2. Accept inputGrade.
3. if inputGrade <= 100
3.1 if inputGrade >= 98
3.1.1 grade = 1.0
4. if inputGrade <= 97
4.1 if inputGrade >= 95
4.1.1 grade = 1.25.
5. if inputGrade <= 94
5.1 if inputGrade >= 91
5.1.1 grade = 1.5.
6. if inputGrade < = 90
6.1 if inputGrade >= 89
6.1.1 grade = 1.75.
else
6.2.1 if inputGrade <= 88 and inputGrade >= 86
6.2.1.1 grade = 2.
else
6.2.1.2 grade = 5.
7. Print the value of grade.
http://ThrivingAndLiving.blogspot.com 12
II. Formulate your own flowchart that will solve the following problems.

1. Show steps on how to withdraw money from ATM. Include situation of what to
do when machine captures your ATM card.

2. Design a modularize approach of how to convert Celcius to Farenheit temperature


and vice versa. The user enters a temperature and later asked on what temperature
conversion will it make. Compute and display the converted temperature value.
Use the following formula in conversion:

Celcius = 5/9 * (Farenheit -32)


Farenheit = 9/5 * Celcius + 32

3. Write a flowchart that will display message “Programming is fun!” 10 times.


Your flowchart should be flexible enough to handle change of number of times
the message is displayed: you only need to change the value 10 into either 5, 15,
100 or 1000 and nothing more.

http://ThrivingAndLiving.blogspot.com 13

You might also like