Lecture 2
Lecture 2
(CIVE)
1
Flowcharts
A flowchart is a graphical representation of an
algorithm.
It depicts a problem in terms of its inputs,
processes, and outputs.
That is, it visually represents and organizes the
steps used to write the program—it is a
diagram of the “flow” of the process.
2
Flowchart Symbols
Input/Output Connector
Flow lines
Process
Pre-defined
Process
Start/End
Decision
3
Flowcharting Rules
Symbols are connected together using different
arrows depending on the direction of flow.
4
Flowcharting Rules..
The Decision symbol has two exit points; these
can be on the sides or the bottom and one side.
Generally, a flowchart will flow from top to
bottom.
Connectors are used to connect breaks in the
flowchart. For example:
o From one page to another
o From bottom of the page to top of the same page
Subroutines and Interrupt programs have their
own independent flowcharts.
5
Flowcharting Rules..
All flowcharts start with a terminal or predefined
process(for interrupt programs or subroutines).
6
Flowcharting Examples
Write a flowchart to compute area of a
rectangle.
Start
Input
l, w
Area=l*w
Output
Area
End
7
Flowcharting Examples..
Write a flowchart that determines the greater
number between two numbers entered.
Start
Input
n1,n2
Yes No
Is
n1>n2?
Output Output
n1 n2
End
8
Flowcharting Examples…
Flowchart to print even numbers between 2 and 100
inclusive.
Start
E:=2
Output
E
E:=E+2
Is Yes
E<=100?
No
End 9
Flowchart Advantages
Communication: It can be used as a better way
of communication of the logic of a system and
steps involved in a solution to all concerned
parties, particularly the client of the system.
Effective Analysis: It can be used to effectively
analyze the problem.
Documentation of program/system:
documents components of the program and its
complexity.
10
Flowchart Advantages..
Efficient Program maintenance: once a
program is developed and becomes operational,
it needs maintenance from time to time.
Flowcharts help to understand the program and
therefore maintenance becomes easier.
Easy Coding of the Program: writing code
resulting from a flowchart is easier than writing
without one.
11