Você está na página 1de 27

DEPARTMENT OF TECHNICAL EDUCATION

Name : G.Venu Gopala Rao


ANDHRA PRADESH
Designation : Lecturer
Branch : Computer Egg.
Institute : Govt. Polytechnic for women,
Bheemunipatnam,VisakhaDist
Year/Semester : III Semester
Subject : UNIX & C
Subject code : CM-304
Topic : Understand Programming
Methodology
Duration : 50 Min
Sub topic : Differentiate Algorithm and
Flowchart, Algorithms for
simple problems
Teaching Aids : Diagrams, Animation Clips, ppts.
CM304.28 1
Objectives

On completion of this period, you would be able to


know

 Differentiate Algorithm and Flowchart.

 Algorithms for simple problems.

CM304.28 2
Recap

In previous period we learnt about

 Steps involved in algorithm development.

 Advantages and disadvantages of algorithm.

CM304.28 3
Algorithm & flowchart

 Both are problem solving approaches .

 Algorithm is a step by step procedure.

 Flowchart is pictorial representation of algorithm.

CM304.28 4
Algorithm Flowchart

 An algorithm is the  A flow chart is a


step by step pictorial
instructions that representation of the
solve a problem. algorithm

CM304.28 5
Algorithm Flowchart

 Algorithm gives verbal  Gives pictorial


representation, which representation.
is almost similar to
English language.

CM304.28 6
Algorithm Flowchart

 Suitable for large and  Suitable for small


modular programs. programs.

CM304.28 7
Algorithm Flowchart

 Easier to understand  To understand


flowchart one has to
be familiar with
symbols.

CM304.28 8
Algorithm Flowchart

 Drawing tools are not  Drawing tools are


required. required

CM304.28 9
Algorithm Flowchart

 Algorithm can be  Flowcharts cannot be


typed so reproduction typed. So

is easy. reproduction is a
problem.

CM304.28 10
Algorithm Flowchart

 It is independent of  We have to use


programming predefined standard
languages. symbols only.

CM304.28 11
Algorithm To Find Sum of Three Numbers

 Step 1:
Read the three numbers x, y, z.
 Step 2:
Sum  x+ y+ z
 Step 3:
Print Sum
 Step 4:
Stop

CM304.28 12
Algorithm to find whether a given number is
positive or negative
 Step 1:
Read the number x
 Step 2:
if (number>0)
Go to step 3
else
Go to step 4
 Step 3:
print the number is positive. Stop.
 Step 4:
print the number is negative. Stop.
CM304.28 13
Algorithm to find adding first 100 natural
numbers
 Step 1:
Input last natural number
 Step 2:
X  (n*(n+1))/2
 Step 3:
Print the value of X
 Step 4:
Stop.
CM304.28 14
Algorithm to find Fahrenheit temperature

 Step 1:
Read centigrade reading
 Step 2:
F  9/5*c+32
 Step 3:
Output the Fahrenheit temperature.
 Step 4
Stop

CM304.28 15
Algorithm to find largest of three numbers
 Step 1: Read three numbers A,B,C
 Step 2:If A>B then go to step 5
else go to step 3.
 Step 3:If B>C then print B is greatest and
go to step 7.
 Step 4: Print C is greatest and go to step7
 Step 5:If A>C then print A is greatest and
go to step7
Else go to step 6
 Step 6:Print C is greatest
 Step 7:Stop.
CM304.28 16
Algorithm to find factorial N

 Step 1:Read the value of N


 Step 2:Assign A=N an B=N
 Step 3:Calculate B=B-1
 Step 4:Calculate A=A*B
 Step 5:If B not equal to 1 then go to step 3
 Step 6:If B equal to 1 then print A
 Step 7:Stop
CM304.28 17
Algorithm for leap year

 Step1: Start
 Step2: Read year
 Step3: Computer year
If year mod 4 is zero
result = “leap year”
 Step4: Print result
 Step5: Stop
CM304.28 18
Summary

We have discussed about

 Difference between algorithm and flowchart.

 Simple algorithms.

CM304.28 19
Quiz

1.Which gives pictorial representation to a problem

(a) Algorithm
(b) Program
(c) Flowchart
(d) None

CM304.28 20
Quiz

1.Which gives pictorial representation to a problem

(a) Algorithm
(b) Program
(c) Flowchart
(d) None

CM304.28 21
Quiz

2.The symbols are used in

(a) Algorithm
(b) Flowchart
(c) Program
(d) None

CM304.28 22
Quiz

2.The symbols are used in

(a) Algorithm
(b) Flowchart
(c) Program
(d) None

CM304.28 23
Quiz

3.Which is easier to understand

(a) Program
(b) Flowchart
(c) Algorithm
(d) None

CM304.28 24
Quiz

3.Which is easier to understand

(a) Program
(b) Flowchart
(c) Algorithm
(d) None

CM304.28 25
Assignment

 Write an algorithm to find sum of first n even

numbers.

CM304.28 26
Frequently Asked Questions

1. Distinguish between algorithm and flowchart.

2. Define algorithm to find biggest of three


numbers.

3. Write algorithm to find a given year leap year or


not.

CM304.28 27

Você também pode gostar