Computer Programming 1
Module 5: Flowcharts in Programming
What is a flowchart?
• A flowchart is a picture (graphical representation) of the problem solving process.
• A flowchart gives a step-by-step procedure for solution of a problem.
History of flowchart
Frank Gilbreth introduced flowcharts in 1921, and they were called “Process Flow
Charts” at the beginning. Allan H. Mogensen is credited with training business people on how to
use flowcharts.
Elements of a flowchart
• Various geometrical shaped boxes represent the steps of the solution.
• The boxes are connected by directional arrows to show the flow of the solution.
Uses of a flowchart
• To specify the method of solving a problem.
• To plan the sequence of a computer program.
• Communicate ideas, solutions.
Drawing a flowchart (Guidelines)
• Identify input and output.
• Apply reasoning skills to solve the problem.
• Draw the flowchart using the appropriate symbols and arrows to show the sequence of
steps in solving the problem.
Flowchart best practices
There are a few things you can do to make your flowchart universally accepted. And
there are some things that you can do to make it visually pleasing to others as well.
If you’re planning to share your flowchart or hoping to use it one presentation etc. then
it’s wise to use standard symbols. However, it is important to remember that the idea is to give
out information in an easy to understand manner. It is perfectly acceptable to use an alternative
image instead of the document symbol as long as the audience understands it.
Keeping the arrow flow to one side, using the same size symbols, naming the decision
blocks, processes, arrows, etc. are few things you can do to make it better.
Some flowchart symbols and their usage
1. Terminal symbol shows where your process starts or ends. You can use words like
“Start” / “End” inside the terminator shape to make things more obvious.
Terminal symbol
2. Preparation symbol displays preparation step by writing the declared variables.
Preparation symbol
3. A Parallelogram is used to show Input or Output. You can use words like “Input” /
“Output” inside the symbol to make things more obvious.
Input or Output symbol
4. Process symbol is used to represent a process, action step or an operation. While
these are pictured with rectangles, the text in the rectangle mostly includes a verb.
Process symbol
5. Decision symbol is represented as a diamond. This object is always used in a process
flow to ask a question. And, the answer to the question determines the arrows coming out of the
diamond. This shape is quite unique with two arrows coming out of it.
Decision symbol
6. On-page Connector symbol indicates the flow continues on the same page. A letter or
page number in the shape tells you where to go.
On-page connector
7. Off-page Connector symbol indicates the flow continues on another page. A letter or
page number in the shape tells you where to go.
Off-page connector
8. Flow line symbols indicates the flow of logic by connecting symbols.
Flow line
Problem #1
Create a flowchart to add two numbers and print its output.
Solution (Program):
first_number = int(input(“Enter first number: ”))
second_number = int(input(“Enter second number: ”))
sum = first_number + second_number
print(sum)
Solution (Flowchart):
Start
first_number
second_number
sum
Input
first_number
Input
second_number
sum = first_number + second_number
Print
sum
End
Problem #2
Create a flowchart to determine if the input number is negative or positive.
Solution (Program):
print(“Positive or Negative number”)
number = int(input(“Enter a number: ”))
if number < 0:
print(“The number is negative.”)
else:
print(“The number is positive.”)
Solution (Flowchart):
Start
number
Input
number
is T Print
number “Negative.” A
< 0?
F
Print
“Positive.”
End
Problem #3
Draw the equivalent flowchart of the program below:
counter = 1
while counter < 6:
print(counter)
counter = counter + 1
Solution (Flowchart):
Start
counter
counter = 1
if T Print
counter counter counter = A
< 6? counter + 1
F
End
Problem #4
Draw the equivalent flowchart of the program below:
print(“Sequence”)
number = int(input(“Enter a number: ”))
if number < 1:
print(“Zero or negative input is not allowed.”)
else:
counter = 1
while counter <= number:
print counter
counter = counter + 1
Solution (Flowchart):
Start
counter
number
Input
number
is T Print
number “Zero or negative input A
< 1? is not allowed.”
counter = 1
if T Print
counter counter counter = B
<= number? counter + 1
F A
End
Problem #5
Draw the equivalent flowchart of the program below:
number = int(input("Enter a number: "))
if number == 1:
print "Excellent."
elif number == 2:
print "Very good."
elif number == 3:
print "Good."
else:
print "Error."
Solution (Flowchart):
Start
number
Input
number
is number Print
“Excellent.” A
== 1?
Print
is number A
“Very Good.”
== 2?
is number Print
“Good.” A
== 3?
Print
“Error.”
https://www.programiz.com
A
https://www.creately.com End