 FLOWCART & ALGORITHMS
What is flowchart ?
 A flowchart is graphical or diagrammatical representation of
sequence of any problem to be solved by computer
programming language.
How it is useful?
 It is used to prepare first before writing any program. It is also
used to correct and debug a program flow after coding part is
completed.
1.flowchart :
Various symbol of flow chart with diagram:
 Start and stop :
 Input/output :
 Decision :
 Connector :
 Loop :
 Process or expression
representation :
 Direction of flow or
flow lines :
Flowchart examples :
1.Draw a flow chart to find factorial of given number :
F=1*2*3*4……..N
start
Read
N
F=1
I=1
Answer :
F=4
Process
no.2
I<=N
Print
“facto=“,f
stop
F=F*I
I=I+1
TrueFalse
N=F=4i=1
1)F=F*I=1*1=1
1) I=1 , F=1
2) I=2 , F=1
3) I=3, F=2
2)F=F*I=1*2=2
3)F=F*I=2*3=6
4)F=F*I=6*4=24
4) I=4, F=6
5) I=5, F=24
4!=1*2*3*4
2.Draw a flow chart to reverse given number.
e.g. 123 --- 321
 Answer :
Sum=0
start
Read
num
stop
r=num%10
Num>0
Num=num/10
sum=sum + r
print
“rvr=“,sum
TrueFalse
Num=123  1.
 r=123 % 10 =3
 Sum = 0 +3 = 3
 num = 123/10 =12
 2.
 r =12 % 10
=2 Sum = 0 +2 = 2
 num = 12/10 =1
 3.
 r =1 % 10 = 1
 Sum = 0 +1 = 1
 num = 1/10 =0
Output :
3 2 1
1) 123>0
2) 12>0
3) 1>0
4) 0>0
Result :
Through flow chart it is easy to understand
the logic and sequence of problem.
After drawing flowchart it becomes easy to
write any program.
2.Algorithms :
 An algorithms is a finite sequence of well
defined steps or operations for solving a
problem in systematic manner.
 These are rules for solving any problems in
proper manner. Instruction are written in
the natural language.
What is algorithms ?
Types of algirithms :
1. Divide and conquer
2. Greedy method
3. Branch and bound
4. Recursion
5. effectiveness
Pseudo code:
 It is language or part of language
used to convert program into easy
form.
 It allows the programmer to write
logic of flowchart or algorithm in
symbolic form.
Pseudo code can be used for folowing situation:
 Storage declaration
 Assignment of any value
 Procedure call
 Input / output
 Constant value
Examples of algorithms :
Step 1 : input number : num
Step 2 : I =1
Step 3 : f =1
Step 4 : repeat from step 4 to step 6 until I<=num
Step 5 : f=f*I
Step 6 : i=i+1
Step 7 : print “ factorial = “,f
Step 8 : stop
1.Write an algorithm to find factorial of given number :
Examples of algorithms :
Step 1 : input number : num
Step 2 : sum=0
Step 3 : repeat from step 3 to step 6 until num>0
Step 4 : calculate r = num % 10
Step 5 : calculate sum = sum * 10 + r
Step 6 : calculate num = num / 10
Step 7 : print “ reverse number = “,sum
Step 8 : stop
2.Write an algorithm to reverse of given number :

Flowchart and algorithem

  • 1.
     FLOWCART &ALGORITHMS
  • 3.
    What is flowchart?  A flowchart is graphical or diagrammatical representation of sequence of any problem to be solved by computer programming language. How it is useful?  It is used to prepare first before writing any program. It is also used to correct and debug a program flow after coding part is completed. 1.flowchart :
  • 4.
    Various symbol offlow chart with diagram:  Start and stop :  Input/output :  Decision :  Connector :  Loop :  Process or expression representation :  Direction of flow or flow lines :
  • 5.
    Flowchart examples : 1.Drawa flow chart to find factorial of given number : F=1*2*3*4……..N start Read N F=1 I=1 Answer : F=4
  • 6.
    Process no.2 I<=N Print “facto=“,f stop F=F*I I=I+1 TrueFalse N=F=4i=1 1)F=F*I=1*1=1 1) I=1 ,F=1 2) I=2 , F=1 3) I=3, F=2 2)F=F*I=1*2=2 3)F=F*I=2*3=6 4)F=F*I=6*4=24 4) I=4, F=6 5) I=5, F=24 4!=1*2*3*4
  • 7.
    2.Draw a flowchart to reverse given number. e.g. 123 --- 321  Answer : Sum=0 start Read num stop r=num%10 Num>0 Num=num/10 sum=sum + r print “rvr=“,sum TrueFalse Num=123  1.  r=123 % 10 =3  Sum = 0 +3 = 3  num = 123/10 =12  2.  r =12 % 10 =2 Sum = 0 +2 = 2  num = 12/10 =1  3.  r =1 % 10 = 1  Sum = 0 +1 = 1  num = 1/10 =0 Output : 3 2 1 1) 123>0 2) 12>0 3) 1>0 4) 0>0
  • 8.
    Result : Through flowchart it is easy to understand the logic and sequence of problem. After drawing flowchart it becomes easy to write any program.
  • 9.
    2.Algorithms :  Analgorithms is a finite sequence of well defined steps or operations for solving a problem in systematic manner.  These are rules for solving any problems in proper manner. Instruction are written in the natural language. What is algorithms ?
  • 10.
    Types of algirithms: 1. Divide and conquer 2. Greedy method 3. Branch and bound 4. Recursion 5. effectiveness
  • 11.
    Pseudo code:  Itis language or part of language used to convert program into easy form.  It allows the programmer to write logic of flowchart or algorithm in symbolic form.
  • 12.
    Pseudo code canbe used for folowing situation:  Storage declaration  Assignment of any value  Procedure call  Input / output  Constant value
  • 13.
    Examples of algorithms: Step 1 : input number : num Step 2 : I =1 Step 3 : f =1 Step 4 : repeat from step 4 to step 6 until I<=num Step 5 : f=f*I Step 6 : i=i+1 Step 7 : print “ factorial = “,f Step 8 : stop 1.Write an algorithm to find factorial of given number :
  • 14.
    Examples of algorithms: Step 1 : input number : num Step 2 : sum=0 Step 3 : repeat from step 3 to step 6 until num>0 Step 4 : calculate r = num % 10 Step 5 : calculate sum = sum * 10 + r Step 6 : calculate num = num / 10 Step 7 : print “ reverse number = “,sum Step 8 : stop 2.Write an algorithm to reverse of given number :