Algorithm&Flowchart
Algorithm&Flowchart
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.
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