CP2 Module 3 - Algorithm and Flowchart
CP2 Module 3 - Algorithm and Flowchart
1. Describe a flowchart
2. Distinguish and describe the various symbols used in creating
a flowchart
3. Differentiate the types of flowcharts
4. Identify basic control structures in flowcharts
5. Create a flowcharts to illustrate the process in solving the
problem
COMPUTER PRORAMMING 2 2
What is a Flowchart?
• planning tool that graphically portrays a
programming task
• visual diagram that shows the logic of
the program or sequence of operations
• use simple geometric shapes to depict
processes and arrows to show data flow
and relationships
COMPUTER PRORAMMING 2 3
Where is Flowchart Useful?
1. Define and analyze processes
2. Build a step-by-step visualization of the
process for analysis, discussion, or
communication
3. Define, standardize or find areas for
improvement in a process
COMPUTER PRORAMMING 2 4
What are the symbols used in Flowchart?
Terminal
Pre-defined
Flow Lines
Process
Preparation
COMPUTER PRORAMMING 2 5
Example of a Flowchart:
COMPUTER PRORAMMING 2 6
Flow Lines [arrow]
• use to show directional flow of the START
process
• connect blocks by exiting from one and A=0
entering another block
• In practice: use a flow line with an
INPUT A
arrowhead
N Y
A = 99
PRINT A
END
COMPUTER PRORAMMING 2 7
Terminal Block [oval or rounded rectangle]
• indicate the start and the end of a flowchart
• mnemonics: (a) Start (b) Stop (c) Return
START
START
X=0
END
X=X-1
STOP
COMPUTER PRORAMMING 2 8
Process Block [rectangular]
• represent arithmetic operations or casing
START
individual variable assignment
• used for opening and closing files X=2
OPERATORS DESCRIPTION
= Equal Y=3
- Subtraction
+ Addition prod = X * Y
/ Division
* multiplication PRINT prod
^ or ** Exponentiation
OPEN for opening file(s)
CLOSE for closing file(s) STOP
COMPUTER PRORAMMING 2 9
Preparation [hexagon]
• Declare and initialize variables needed to solve a
particular process
• Declaration num1,
num2
fname,
lname
➢ state a variable name
num1 = 2 fname = "Jose"
• Initialization num2 = 5 lname = "Garcia"
➢ set a starting value
COMPUTER PRORAMMING 2 10
Preparation [hexagon]
• Declare and initialize variables
START
needed to solve a particular START
process X=0
X=0
• Declaration Y=0
➢ state a variable name Y=0
• Initialization INPUT X, Y
INPUT X, Y
STOP
STOP
COMPUTER PRORAMMING 2 11
Input/Output Block [parallelogram]
• indicates input and output operations
• specifies the link between input & output START
devices
X=0
STATEMENT DESCRIPTION
INPUT/GET/ENTER - when data is keyed-in from the keyboard
READ - when data is retrieved from disk storage INPUT X
WRITE - when data is stored on disk storage
PRINT - when the result is sent to the printer PRINT X
DISPLAY - when the output is displayed on the screen
STOP
COMPUTER PRORAMMING 2 12
Decision [diamond]
• use to evaluate conditional statement and START
branch out to the required process depending
on the outcome of the test
A=0
• One exit for "True" and one exit for "False"
LOGICAL SYMBOLS
SYMBOLS DESCRIPTION INPUT A
= - Equal
> - Greater than
< - Less than N Y
A = 99
!= - Not equal to
>= - Greater than or equal to PRINT A
END
<= - Less than or equal to
COMPUTER PRORAMMING 2 13
Pre-defined Process
• Indicates another block of code
containing processing steps
which are declared but START
SUB-TEST PRINT X
RETURN
STOP
COMPUTER PRORAMMING 2 14
Connectors [small circle or pentagon]
• Connections between two sections of a flowchart
• Labeled with a number or uppercase alphabet
• On-page connector
• use if jump is within the same page
• use a small circle as symbol
• Off-page connector
• use if jump is located in another page
• use a pentagon as symbol
COMPUTER PRORAMMING 2 15
On-page Connector [small circle]
START
S
X=0
Y=0 Y=Y+X
INPUT X, Y PRINT X, Y
X = X ** 5 STOP
COMPUTER PRORAMMING 2 16
On-page Connector [small circle]
Page 1 Page 2
START
P
X=0
Y=0
Y=Y+X
INPUT X, Y
PRINT X, Y
X = X ** 5
P STOP
COMPUTER PRORAMMING 2 17
Annotations
• used to indicate a procedural-name or remark to emphasize
a part of the flowchart
• the remark or name must be written within its range
START MAIN-ROUTINE
INPUT X
N Y
X > 0
SUB-TEST PRINT X
RETURN
STOP
COMPUTER PRORAMMING 2 18
Rules in Creating a Flowchart
1. Every flowchart has a START symbol and a STOP symbol.
2. The flow of sequence is generally from the top of the page to the bottom
of the page. This can vary with loops which need to flow back to an entry
point.
3. Use arrow-heads on connectors where flow direction may not be
obvious.
4. There is only one flowchart per page.
5. A page should have a page number and a title.
6. A flowchart on one page should not break and jump to another page.
7. A flowchart should have no more than around 15 symbols(not including
START and STOP).
COMPUTER PRORAMMING 2 19
COMPUTER PRORAMMING 2 20
Resources:
• Padre, Nilo M. et al. (2016). Programming Concepts Logic Formulation, 1st ed.
Manila: Unlimited Books Library Services & Publishing, Inc.
• How to Create a Flowchart: Logic Formulation. ITS InfoTechSkills (2020).
Retrieved from: https://www.youtube.com/watch?v=YwE6yqi-37Y
• FLOWCHART AND ALGORITHM SAMPLE PROBLEMS. ITS InfoTechSkills (2020).
Retrieved from: https://www.youtube.com/watch?v=BQP2doXjVlQ
• Programming Fundamentals #3: Algorithm & Flowchart. SDFT Solutions (2019).
Retrieved from: https://www.youtube.com/watch?v=szyhF3yvu3k
COMPUTER PRORAMMING 2 21
COMPUTER PRORAMMING 2