Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 24

Flowchart

MR. MADHUR THAPLIYAL


ASSISTANT PROFESSOR
SCHOOL OF COMPUTING
DEPARTMENT OF COMPUTER APPLICATIONS
GRAPHIC ERA HILL UNIVERSITY
Definition

 Flowchart is a graphical representation of an


algorithm. Programmers often use it as a program-
planning tool to solve a problem. It makes use of
symbols which are connected among them to indicate the
flow of information and processing.

The process of drawing a flowchart for an algorithm is
known as “flowcharting”.
Symbols used in Flowchart Designs

 Terminal: The oval symbol indicates Start, Stop and Halt in a


program’s logic flow. A pause/halt is generally used in a program
logic under some error conditions. Terminal is the first and last
symbols in the flowchart.
 INPUT/OUTPUT: A parallelogram denotes any function of
input/output type. Program instructions that take input from input
devices and display output on output devices are indicated with
parallelogram in a flowchart.
 Processing : A box represents arithmetic instructions. All arithmetic
processes such as adding, subtracting, multiplication and division
are indicated by action or process symbol.
 Decision :Diamond symbol represents a decision point. Decision
based operations such as yes/no question or true/false are indicated
by diamond in flowchart.
 Connectors :Whenever flowchart becomes complex or it spreads
over more than one page, it is useful to use connectors to avoid any
confusions. It is represented by a circle.
 Flowlines : Flow lines indicate the exact sequence in which
instructions are executed. Arrows represent the direction of flow of
control and relationship among different symbols of flowchart.
Rules for creating a flowchart

 A flowchart is a graphical representation of an algorithm.it should


follow some rules while creating a flowchart
Rule 1: Flowchart opening statement must be ‘start’ keyword.
Rule 2: Flowchart ending statement must be ‘end’ keyword.
Rule 3: All symbols in the flowchart must be connected with an
arrow line.
Draw a flowchart to check largest no among
two

Algorithm Flowchart
 1. Start
 2. Input 2 variables from user
 3. Now check the condition If a > b, goto step
4, else goto step 5.
 4. Print a is greater, goto step 6
 5. Print b is greater
 6. Stop
Draw a flowchart to check whether the input
number is odd or even

Algorithm Flowchart
 1. Start
 2. Put input a
 3. Now check the condition if a % 2 == 0, goto
step 5. Else goto step 4
 4. Now print(“number is odd”) and goto step 6
 5. Print(“number is even”)
 6. Stop
Draw a flowchart to print the input number 5
times.

Algorithm Flowchart
 1. Start
 2. Input number a
 3. Now initialize c = 1
 4. Now we check the condition if c <= 5, goto step
5 else, goto step 7.
 5. Print a
 6. c = c + 1 and goto step 4
 7. Stop
Sequential flowchart

 The term sequential flowchart chart (SFC) is used for a pictorial


representation of a system's operation to show the sequence of events
involved in its operation.
 The operation is described by a number of separate sequentially connected
states or steps that are represented by rectangular boxes, each
representing a particular state of the system being controlled.
 If we wanted to describe a traffic lamp sequence, one way we could do
this would be to represent it as a sequence of functions or states such as
red light state and green light state and the inputs and outputs to each
state.
 State 0 has an input that is triggered after the green light has been on
for 1 minute and an output of red light on. State 1 has an input that is
triggered after the red light has been on for 1 minute and an output of
green light on.
 Each connecting line between states has a horizontal bar representing the transition
condition that has to be realized before the system can move from one state to
the next. Two steps can never be directly connected; they must always be
separated by a transition. Two transitions can never directly follow from one to
another; they must always be separated by a step.

When the transfer conditions to the next state are realized, the next state or
step in the program occurs.
 The process thus continues from one state to the next until the complete machine
cycle is completed.
 Outputs/actions at any state are represented by horizontally linked boxes and occur
when that state has been realized.
Show the sequence of states of this…

 The washing cycle of a domestic washing machine where the drum is to be


filled with water, and then when the drum is full, a heater has to be switched
on and remain on until the temperature reaches the required level. Then the
drum is to be rotated for a specified time.
Conditional flowchart

 A conditional flowchart is used when a condition is imposed on a problem. The


condition will either be true or false. The course of the problem depends on
the answer to the condition.
 The condition will be specified within the following shape:
Check if the number is the multiple of 3 or
not

1. Input the number 'n'.

2. Divide 'n' be 3.

3. If reminder equals 0, print 'n' is a multiple of 3'.

4. If reminder does not equal to 0, print 'n' is not a multiple of 3'.


Start

Input the no
N

Divide no N by 3

Reminder
=0? Print N is not
multiple of 3

 Print N is a multiple of 3

End
Iterative flowchart

 When designing algorithms, there may be some steps


that need repeating. This is known as iteration.
 There are two ways of representing algorithms:
• pseudocode
• a flowchart
 Writing in pseudocode is rather like writing in
a programming language. Each step of the algorithm is
written on a line of its own, in sequence.
Consider this simple six-step algorithm
for cleaning your teeth:

1. set number_of_teeth_cleaned to 0
2. put toothpaste on toothbrush
3. use toothbrush to clean a tooth
4. increase number_of_teeth_cleaned by 1
5. if number_of_teeth_cleaned < 32 then go back to step 3
6. rinse toothbrush
In pseudocode, the algorithm would
look like this:

 number_of_teeth_cleaned = 0
 put toothpaste on toothbrush
 REPEAT
 procedure clean_tooth
 number_of_teeth_cleaned = number_of_teeth_cleaned + 1
 UNTIL number_of_teeth_cleaned = 32
 rinse toothbrush
Thank You

You might also like