0% found this document useful (0 votes)
16 views18 pages

1.2-Algorithm & Flow Chart

Algorithm and Flow Chart

Uploaded by

Sivan N
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
0% found this document useful (0 votes)
16 views18 pages

1.2-Algorithm & Flow Chart

Algorithm and Flow Chart

Uploaded by

Sivan N
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/ 18

Algorithm &

Flow Chart (2 Hrs)

Dr. D. NATARAJASIVAN
Lecturer
TNPT
D.NATARAJASIVAN/ TNP
T

Topics
▪ Algorithm-Definition
▪ Properties and Classification of
Algorithm
▪ Flow Chart-Symbols
▪ Importance and Advantages of Flow
Chart
▪ Algorithm and Flow Chart for problems
D.NATARAJASIVAN/ TNP
T

Algorithm Definition

▪ An algorithm is a set of
step-by-step instructions
written in simple English
to perform a specific
task.
D.NATARAJASIVAN/ TNP
T

Properties of Algorithm

▪ Easy to understand
▪ Input and Output are clearly
defined
▪ Calculation steps are clearly given
▪ Does not contain any program code
▪ Written in finite steps
D.NATARAJASIVAN/ TNP
T

Classification of Algorithm

▪ Algorithm designed based on


basic principles
– Sequential
– Parallel
– Recursive
– Logical
– Deterministic
– Non-deterministic
D.NATARAJASIVAN/ TNP
T

Flow Chart - Symbols

▪ It is the symbolic representation


of the algorithm
▪ Start/Stop –
▪ Input / Output –
▪ Calculation –
▪ Decision –
D.NATARAJASIVAN/ TNP
T

Contd…

▪ For Loop –
▪ Sub process –
▪ Flow Direction –
▪ Connector –
D.NATARAJASIVAN/ TNP

Importance and T

advantages of Flow Chart


▪ Clear understanding of the
concept of the program
▪ Proper program
documentation
▪ Efficient coding
▪ Easy to test and debug
D.NATARAJASIVAN/ TNP

Area and Circumference T

of Circle
▪ Algorithm
Step 1) Start.
Step 2) Get radius r value.
Step 3) Calculate area as (22/7) * r * r.
Step 4) Calculate circumference as
2*(22/7)*r.
Step 5) Display area and circumference.
Step 6) Stop.
Flow Chart
Start

Get r value
Area = (22/7) * r *
r
Circum =
2*(22/7)* r
Display
area and
Circum
Stop
D.NATARAJASIVAN/ TNP

Product of first N natural T

numbers
▪ Algorithm
Step 1) Start
Step 2) Get value for N
Step 3) Initialize res = 1
Step 4) For i = 1 to N do the following
i) Calculate res = res * i
Step 5) Next i
Step 6) Display res
Step 7) Stop
Flow Chart
Start
A
Get N
Display
value
res
res = 1
Stop
for i = 1 to N

res = res * i

Next
i A
D.NATARAJASIVAN/ TNP
T

Largest of 3 Numbers
▪ Algorithm
Step 1) Start
Step 2) Get values for a,b,c
Step 3) Check if a>b and a>c then
i) Display ‘a’ is largest
Step 4) Else check if b>c then
i) Display ‘b’ is largest
Step 5) Else
i) Display ‘c’ is largest
Step 6) Stop
D.NATARAJASIVAN/ TNPT
Flow Chart
Start
Get a,b,c
If
a>b False
&
Truea>c
Display If False
‘a’ is b>c
True
Display Display
largest
‘b’ is ‘c’ is
largest largest

Stop
D.NATARAJASIVAN/ TNP
T

Number ODD or EVEN

▪ Algorithm
Step 1) Start
Step 2) Input n
Step 3) Calculate res = n mod 2
Step 4) If res equal to 0 then
i) Display “Even”
Step 5) else
i) Display “Odd”
Step 6) Stop
D.NATARAJASIVAN/ TNPT
Flow Chart
Start
Input n
res = n mod 2

If res False
== 0
True
Display Display
“Even” “Odd”

Start
Factorial of a given D.NATARAJASIVAN/ TNP
T

number

▪ Algorithm
Step 1) Start
Step 2) Input n
Step 3) Initialize fact = 1
Step 4) While n >= 1 do the following
i) calculate fact = fact * n
ii) calculate n = n – 1
Step 5) Output fact
Step 6) Stop
D.NATARAJASIVAN/ TNPT
Flow Chart Start
Input n
fact =1
Whil
e
n False
>=
True
fact =1 fact
*n
n=n-1

Output
fact
Stop

You might also like