100% found this document useful (4 votes)
466 views35 pages

Introduction To FlowCharts

This document provides an introduction to flowcharting. It discusses the main components of a flowchart including flowchart symbols like terminals, processes, decisions, and repetition structures. It explains how to represent sequence, selection, and repetition using flowcharts. Sequence shows a linear series of steps. Selection, including binary and multi-way, indicates conditional steps. Repetition uses loops to repeat steps while a condition is true. The document emphasizes that flowcharts provide an effective way to visually represent algorithms and guide program development.

Uploaded by

BINJAD
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
100% found this document useful (4 votes)
466 views35 pages

Introduction To FlowCharts

This document provides an introduction to flowcharting. It discusses the main components of a flowchart including flowchart symbols like terminals, processes, decisions, and repetition structures. It explains how to represent sequence, selection, and repetition using flowcharts. Sequence shows a linear series of steps. Selection, including binary and multi-way, indicates conditional steps. Repetition uses loops to repeat steps while a condition is true. The document emphasizes that flowcharts provide an effective way to visually represent algorithms and guide program development.

Uploaded by

BINJAD
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 35

Introduction To

Flowcharting

Todays Topics
Flowchart Symbols
Structures
Sequence
Selection
Repetition

1. Flowchart:
O The flowchart is a means of visually presenting

the flow of control


processing systems,

through

an

information

O the operations performed within the system and the

sequence in which they are performed.


O It is a graphic representation of how a process

works, showing, at a minimum, the sequence of


steps.
O Represents an algorithm in graphical symbols.
O Flowcharts are generally drawn in the early

stages of formulating computer solutions.

2. Flowchart Symbols
Terminal:
Used to indicates the start and end of a
flowchart.
Single flow line.
Only one Start and Stop terminal for each
program.
The end terminal for function/subroutine must
use Return instead of Stop.
Process:
Used whenever data is being manipulated.
One flow line enters and one flow line exits.
Input/Output:
Used whenever data is entered (input) or
displayed (output).
One flow line enters and one flow line exits.

2. Flowchart Symbols
Decision:
Used to represent operations in which
there are two possible selections.
One flow line enters and two flow lines
(labeled as Yes and No) exit.
Function / Subroutine:
Used to identify an operation in a separate
flowchart segment (module).
One flow line enters and one flow line
exits.
On-page Connector:
Used to connect remote flowchart portion
on the same page.
One flow line enters and one flow line
exits.

2.Flowchart Symbols
Off-page Connector:
Used to connect remote flowchart portion
on different pages.
One flow line enters and one flow line
exits.
Comment:
Used to add descriptions or clarification.
Flow line:
Used to indicate the direction of flow of
control.

3.1 Comments or description

Start

Read N,
M

Yes

No

Stop

N = The number of students


M = The number of subjects

3.2 Connectors on the same page


Start

1- connection on the same


flowchart portion

Stop
1

2- connection on the different


flowchart portion

3.3 Connectors on a different page


Page 2

Page 1

Start
2
1

Stop
Yes

No
2

The detail of how the function works


is put in another flowchart.
This is known as Function-Definition

3.4 Function
Page 1
Start

Page 2

Start terminal for a


Function is different.
Do not use Start

AVRG ( result,n1, n2,n3)

Read
n1, n2 , n3

sum = n1+ n2+n3

AVRG (result, n1, n2,n3)

At this point,
we only focus on what
to do. How to do it,
it comes later.

Body of a function is
the same with
normal flowchart
result = sum/3

Print
result

This part is known as


Function-Call

Return

Stop

End terminal
must be a Return

This flowchart calculates the average of three numbe

ADVANTAGES OF USING FLOWCHARTS:


O Communication: Flowcharts are better way of

communicating the logic of a system.


O Effective analysis: Problem can be analyzed

in more effective way.


O Proper documentation: Flowcharts serve as

a good program documentation.


O Efficient Coding: Flowcharts act as a guide or

blueprint during the systems analysis and


program development phase.

ADVANTAGES OF USING FLOWCHARTS (Contd):

O Proper

Debugging: Flowchart helps in


debugging process.

O Efficient

Program Maintenance: The


maintenance of operating program becomes
easy with the help of flowchart.

4. The main Flowcharting Structures


1) Sequence
2) Selection
3) Repetition
O) A flowchart expressing the solution to an involved

problem may have:


i. the main program flowchart on one page
ii. with subprograms continuing the problem
solution on subsequent pages.

4.1 Each of the five acceptable


structures can be built from the basic
elements as shown below.

4.2 Each of the five acceptable


structures can be built from the basic
elements as shown below.

4.3 Each of the five acceptable


structures can be built from the basic
elements as shown below.

4.4.1 Sequence :
In a computer program or an algorithm, sequence
involves simple steps which are to be executed one
after the other.
The steps are executed in the same order in which they are
In a flowchart,
written.
sequence is expressed as:

In pseudocode,
sequence is expressed
as:
process 1
process 2

process n

4.4.1 Sequence

An Example Using Sequence

Problem: Write a set of instructions that describe how to make


a pot of tea.
Pseudocode
Flowchart
BEGIN
fill a kettle with water
boil the water in the
kettle
put the tea leaves in the
pot
pour boiling water in the
pot
END

4.4.2 Selection :

Binary

(structure)

Selection is used in a computer program or algorithm


to determine which particular step or set of steps is to
be executed.

Binary Selection

Binary Selection

In pseudocode, binary
selection is expressed in the
following ways:

In flowcharts, binary selection is expressed in


the following ways:

1.

IF condition THEN
process 1
ENDIF

2. IF condition THEN
process 1
ELSE
process 2
ENDIF

4.4.2 Selection :

Binary

(structure)

Binary Selection

Binary Selection

In pseudocode, binary
selection is expressed in the
following ways:

In flowcharts, binary selection is


expressed in the following ways:

1.

IF condition THEN
process 1
ENDIF

2.

IF condition THEN
process 1
ELSE
process 2
ENDIF

4.4.2 Selection :

Binary (flowchart structure)

Note: In a flowchart it is most important to indicate


1) which path is to be followed when the condition is true, and
2) which path to follow when the condition is false.
Without these indications the flowchart is open to more than one
interpretation.
Note: There are two acceptable ways to represent a decision in all
of the structures.

Either method is acceptable.


) For consistency, the method 1 is used throughout this document.
1. The condition
is expressed as a
2. The condition is expressed as a

statement and the two possible


outcomes are indicated by
True
False

question and the two possible


outcomes are indicated by
Yes
No

4.4.2 Selection :

Binary

(examples)

Selection is used in a computer program or algorithm to determine


which particular step or set of steps is to be executed.

Examples Using Binary Selection


Problem 1: Write a set of instructions to describe when to answer
the phone.
Binary Selection
Pseudocode
IF the telephone is ringing THEN
answer the telephone
ENDIF

Binary Selection
Flowchart

4.4.2 Selection :

Binary

(examples)

Examples Using Binary Selection


Problem 2: Write a set of instructions to follow when approaching a set of
traffic control lights.

Binary Selection
Pseudocode
IF the signal is green
THEN
proceed through
the intersection
ELSE
stop the vehicle
ENDIF

Binary Selection
Flowchart

4.4.2 Selection :

Multi-way

(structure)

Multi-way Selection

Multi-way Selection

In pseudocode, multiple
selection is expressed as:

In flowcharts, multi-way selection is


expressed as:

CASEWHERE expression
evaluates to
choice a
:
process a
choice b
:
process b
.
.
.
.
.
.
OTHERWISE :
default
process
ENDCASE
Note: As the flowchart version
of the multi-way selection
indicates, only one process
on each pass is executed as a
result of the implementation of

4.4.2 Selection :

Multi-way

(examples)

Example Using Multi-way Selection


Problem: Write a set of instructions that describes how to:
respond to all possible signals at a set of traffic control lights.

Multi-way Selection
Pseudocode
CASEWHERE signal is
red
: stop the
vehicle
amber
: stop the
vehicle
green
: proceed
through the intersection
OTHERWISE : proceed
with caution
ENDCASE

Multi-way Selection
Flowchart

Repetition
Repetition allows for a portion of an algorithm or computer
program
to be done any number of times
dependent on some condition being met.
An occurrence of repetition is usually known as a loop.
An essential feature of repetition is that
each loop has a termination condition
to stop the repetition,
or the obvious outcome is that
the loop never completes execution (an infinite loop).
The termination condition can be checked or tested
1. at the beginning and is known as a pre-test loop or
2. at the end of the loop and is known as a post-test
loop.

Repetition
Pre-test

(structure)

Repetition: Pre-Test
A pre-tested loop is so named because the condition has to be met at
the very beginning of the loop or the body of the loop is not executed.
This construct is often called a guarded loop.
The body of the loop is executed repeatedly while the termination condition is true.

Repetition

Repetition
In pseudocode, pre-test
repetition is expressed as:
WHILE condition is true
process(es)
ENDWHILE

In flowcharting
pre-test repetition
is expressed as:

Repetition

Post-test

(structure)

Repetition: Post-Test

A post-tested loop executes the body of the loop before testing the
termination condition.

This construct is often referred to as an unguarded loop.

The body of the loop is repeatedly executed until the termination condition is
true.
An important difference between a pre-test and post-test loop is that the
statements of a post-test loop are executed at least once even if the
condition is originally true, whereas the body of the pre-test loop may never be
executed if the termination condition is Repetition
originally true.
A close look at the representations of the two loop types makes this point apparent.

Repetition

In pseudocode, post-test
repetition is expressed as:
REPEAT
process
UNTIL condition is true

In a flowchart
post-test repetition
is expressed as:

Repetition

Pre-test

(example)

An Example Using Pre-Test Repetition


Problem: Determine a safety procedure for travelling in a carriage on a moving train.

Pre-test Repetition
Flowchart

Pre-test
Repetition
Pseudocode
WHILE the train is
moving
keep wholly within
the carriage
ENDWHILE

Repetition

Post-test

(example)

An Example Using Post-Test Repetition


Problem: Determine a procedure to beat egg whites until fluffy.

Post-test Repetition
Flowchart

Post-test Repetition
Pseudocode
REPEAT
beat the egg whites
UNTIL fluffy

Example:
Start

Read
Length,
Width

Calculate Area
Area=Length * Width

Calculate Perimeter
Perimeter=
2 * (Width+Length)

Print
Area,
Perimeter

Stop

Input:
Length <- 5
Width <- 3

Process:
Area = 5 * 3 = 15

Process:
Perimeter =
2* (5+3)

= 16

Output
Area: 15
Perimeter: 16

Example:
What is the output of the following flowchart when the input Num= 10
Start

Enter a Number >> 10


Input:
Num <- 10

Read Num

Num = 10
10 > 0 ? => YES

Num>0?

No
Print
"Category B"

Yes
Print
"Category A"

Stop

Output:
Category A

Category A

Example:
What is the output of the following flowchart when the input is Num= 0
Start

Enter a Number >> 0


Input:
Num <- 0

Read Num

Num = 0
0 > 0 ? => NO

Num>0?

No
Print
"Category B"

Yes
Print
"Category A"

Stop

Category B
Category A

Output:
Category A

Output:
Category B

Example:
What is the output of the following flowchart when the input is Num= 4

Variables
Variables
(in
memory):
Variables(in
(inmemory):
memory):

Start

Input:
Num <- 4

Read Num

Num
Num
Num
[[[ 444 ]]]
Result
Result
9 ]]] 0497 +++ 4312
Result [[[ 0
4710]
Count
Count
420
1 ]]] 4312 --- 111
Count [[[ 3

Initialize
Result=0
Count=Num

Enter a Number => 4


Print Count
Count
Count
Count=
Count
===4
132
0
4
=>
=>YES
YES
YES
132>
0
>>>0
000?? ??=>
=>
YES
NO

Result=Result + Count
Count>0?

Yes
Count=Count - 1

No

Print
Result

Stop

Count: 4
Count: 3
Count: 2
Count: 1
Count: 0
Result: 10

Example:
What is the output of the following flowchart when the input is N = 6
10
Page 1

average

Page 2

Start

5
N=6

AVRG ( result,n1, n2,n3)

Read
N

Sum = 10 + 5 + 6
sum = n1+ n2+n3

average =
21/3

AVRG (average, 10, 5, N)

result = sum/3
Print
average

Output:
Average: 7
Return

Stop

You might also like