0% found this document useful (0 votes)
5 views

Algorithm&Flowchart

Uploaded by

asteyaananda
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)
5 views

Algorithm&Flowchart

Uploaded by

asteyaananda
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/ 13

ALGORITHM : An algorithm is step by step description of the method to

solve a given problem.


ALGORITHM
ALGORITHM : An algorithm is step by step description of the method to
solve a given problem.
Problem : How to make tea?
Algorithm :
Step 1 : Start
Step 2 : Take a steel pot
Step 3 : Pour water into the pot
Step 4 : Boil water
Step 5 : Add tea leaves and ginger
Step 6 : Add sugar and milk
Step 7 : Boil the mixture for some
time
Step 8 : Tea is ready for consumption
Step 9 : Stop
Algorithm of daily routine of students of Navodaya Vidyalaya
Step 1 : Start
Step 2 : Wake up at 5 AM
Step 3 : Morning PT
Step 4 : Bath and Change
Step 3 : Academic time
Step 4 : Lunch
Step 5 : Remedial study
Step 6 : Games
Step 7 : Evening Assembly
Step 8 : Supervised study
Step 9 : Dinner
Step 10 : Self study in dormitories
Step 11: Lights Off
Step 12 : Stop
Problem : Add and subtract two numbers
Algorithm :
Step 1 : Start
Step 2 : Input two numbers say a,b.
Step 3 : Add a and b and store it in c
Step 3 : Subtract b from a and store it in d
Step 4 : Display the computed sum , i.e. c
Step 5: Display the computed difference , i.e. d
Step 6 : Stop
Problem : Display greatest of three numbers

Algorithm :
Step 1 : Start
Step 2 : Input three numbers say a,b,c
Step 3 : if a>b , then go to step 6
Step 4 : if b>c,print b is the largest number and go to step 8
Step 5: print c is largest and go to step 8
Step 6 : if a>c,print a is the largest number and go to step 8
Step 7 : print a is largest number
Step 8 : Stop
Problem : To check whether a number is prime

Algorithm :
Step 1 : Start
Step 2 : Input number say a
Step 3 : x=2
Step 4 : if x>a-1 print a is prime and go to step 10
Step 6 : Divide a by x and store remainder in r
Step 7 : if r=0 and x<=a-1 print a is not prime and go to step 10
Step 8 : Increment x by 1
Step 9 : Go to step 4
Step 10 : Stop
FLOWCHART : Flowchart is a diagrammatical representation of
step by step approach to solve a problem. The steps are depicted
by different type of boxes connected with arrows.

COMMONLY USED FLOWCHART SYMBOLS :

a) Terminal Box : This is also called


START
start/stop box.It is oval shaped.When it
is used in beginning it is called START
box and when used at end it is
called STOP box. STOP
b) Input/Output Box : This
INPUT A,B
parallelogram shaped box is used
for input/otput and display
operations. PRINT C

c) Process Box : This A=0


rectangle shaped box is used B=A+C
for any type of computation C=A*D
D=A/B
d) Flow Lines: These arrowhead line depicts
direction of flow of data and information ,in
addition to connecting different boxes of
flowchart.

e) Decision Box : This diamond box is


used to represent decisions based on
IIF
a condition . NO
A>=0
YES

if a>=0 print a is non-negative


otherwise print a is negative

APRINT A APRINT A
IS -ve IS +ve
EXAMPLES OF FLOW CHART :
EXAMPLE 1 : Flowchart to compute simple interest.
Start

IINPUT
P,R,T P – PRINCIPAL
R- RATE
SI=P×R×T T- TIME
SI- SIMPLE INTEREST

PRINT SI

Stop
EXAMPLE 1 : Flowchart to check whether number is even or odd.
Start

IINPUT A

R=A MOD 2

NO IF YES
R=0

PRINT A PRINT A
IS ODD IS EVEN

Stop
EXAMPLE 1 : Flowchart to print numbers from 1 to 10
Start

x=1

PRINT x

IF
x=x+1
x<=10

Stop

You might also like