Algorithm & Flow Charts Presented By Manesh T Course:1090 CS.
-
Upload
shanon-strickland -
Category
Documents
-
view
233 -
download
2
Transcript of Algorithm & Flow Charts Presented By Manesh T Course:1090 CS.
![Page 1: Algorithm & Flow Charts Presented By Manesh T Course:1090 CS.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ef55503460f94c08e32/html5/thumbnails/1.jpg)
Algorithm & Flow Charts
Presented ByManesh TCourse:1090 CS
![Page 2: Algorithm & Flow Charts Presented By Manesh T Course:1090 CS.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ef55503460f94c08e32/html5/thumbnails/2.jpg)
ALGORITHMS AND FLOWCHARTS
Algorithm Step by step method to solve a problem is algorithm
Flow Chart Diagrammatic representation of algorithm
![Page 3: Algorithm & Flow Charts Presented By Manesh T Course:1090 CS.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ef55503460f94c08e32/html5/thumbnails/3.jpg)
Algorithm
Example 1:
Write an algorithm to Add two numbers
![Page 4: Algorithm & Flow Charts Presented By Manesh T Course:1090 CS.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ef55503460f94c08e32/html5/thumbnails/4.jpg)
Problem: Add two numbers
Step 1: Start Step 2: Read A, B
Step 3: C=A+B Step 4: Print C Step 5: Stop
![Page 5: Algorithm & Flow Charts Presented By Manesh T Course:1090 CS.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ef55503460f94c08e32/html5/thumbnails/5.jpg)
AlgorithmProblem: Multiply 2 numbersStep 1: StartStep 2: Read A, BStep 3: C=A*BStep 4: Print C Step 5: Stop
Problem: Subtract 2 numbers
Step 1: StartStep 2: Read A, BStep 3: C=A-BStep 4: Print C Step 5: Stop
![Page 6: Algorithm & Flow Charts Presented By Manesh T Course:1090 CS.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ef55503460f94c08e32/html5/thumbnails/6.jpg)
AlgorithmProblem: Average of 3 numbers
Step 1: Start Step 2: Read A, B, C
Step 3: Avg=(A+B+C)/3 Step 4: Print Avg Step 5: Stop
![Page 7: Algorithm & Flow Charts Presented By Manesh T Course:1090 CS.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ef55503460f94c08e32/html5/thumbnails/7.jpg)
AlgorithmProblem: Find your Age Step 1: Start Step 2: Read Byear
Step 3: Age=2015-Byear Step 4: Print Age
Step 5: Stop
![Page 8: Algorithm & Flow Charts Presented By Manesh T Course:1090 CS.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ef55503460f94c08e32/html5/thumbnails/8.jpg)
AlgorithmProblem: Area of Circle Step 1: Start Step 2: Read Radius
Step 3: Area=3.14*Radius *Radius Step 4: Print Area
Step 5: Stop
![Page 9: Algorithm & Flow Charts Presented By Manesh T Course:1090 CS.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ef55503460f94c08e32/html5/thumbnails/9.jpg)
AlgorithmProblem: Find even or odd
Step 1: Start Step 2: Read N
Step 3: Is (N%2=0) thenPrint “Even”
elsePrint “Odd”
Step 4: Stop
![Page 10: Algorithm & Flow Charts Presented By Manesh T Course:1090 CS.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ef55503460f94c08e32/html5/thumbnails/10.jpg)
Detailed Algorithm Step 1: Start Step 2: Read M1,M2,M3,M4
Step 3: GRADE M1+M2+M3+M4Step 4: Is (GRADE < 60) then
Print “FAIL” else
Print “PASS”Step 5: Stop
AlgorithmProblem: Find Pass or Fail
![Page 11: Algorithm & Flow Charts Presented By Manesh T Course:1090 CS.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ef55503460f94c08e32/html5/thumbnails/11.jpg)
The FlowchartA Flowchart is another algorithm but graphical.
shows logic solutionemphasizes individual steps and their
interconnectionsA flowchart must have a start and stopA steps in a flowchart must connect.
![Page 12: Algorithm & Flow Charts Presented By Manesh T Course:1090 CS.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ef55503460f94c08e32/html5/thumbnails/12.jpg)
Flowchart Symbols General Used Symbols
![Page 13: Algorithm & Flow Charts Presented By Manesh T Course:1090 CS.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ef55503460f94c08e32/html5/thumbnails/13.jpg)
Flow Chart: Add Two NumbersStart
Read A, B
C=A+B
Print C
Stop
Algorithm
Flowchart
![Page 14: Algorithm & Flow Charts Presented By Manesh T Course:1090 CS.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ef55503460f94c08e32/html5/thumbnails/14.jpg)
DECISION STRUCTURES
The expression A>B is a logical expression it describes a condition we want to test if A>B is true (if A is greater than B) we take
the action on left print the value of A if A>B is false (if A is not greater than B) we
take the action on right print the value of B
![Page 15: Algorithm & Flow Charts Presented By Manesh T Course:1090 CS.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ef55503460f94c08e32/html5/thumbnails/15.jpg)
DECISION STRUCTURES
isA>B
Y N
Print A Print B
![Page 16: Algorithm & Flow Charts Presented By Manesh T Course:1090 CS.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ef55503460f94c08e32/html5/thumbnails/16.jpg)
Flow Chart: Find Even or OddStart
Read N
Print “Odd”
Stop
Print “Even”
IsN%2=0
NY
![Page 17: Algorithm & Flow Charts Presented By Manesh T Course:1090 CS.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ef55503460f94c08e32/html5/thumbnails/17.jpg)
Flow Chart: Find Largest of two numbersStart
Read A, B
Print “B is large”
Stop
Print “A is large”
IsA>B
NY
![Page 18: Algorithm & Flow Charts Presented By Manesh T Course:1090 CS.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ef55503460f94c08e32/html5/thumbnails/18.jpg)
Problem: Write Algorithm and Flowchart to find solution of Quadratic equation
Algorithm: Step 1: Start Step 2: Read a, b, c Step 3: d sqrt ( ) Step 4: x1 (–b + d) / (2 x a) Step 5: x2 (–b – d) / (2 x a) Step 6: Print x1, x2 Step 7: Stop
START
Reada, b, c
d sqrt(b x b – 4 x a x c)
STOP
x1 (–b + d) / (2 x a)
X2 (–b – d) / (2 x a)
4b b a c
Print X1, X2
![Page 19: Algorithm & Flow Charts Presented By Manesh T Course:1090 CS.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ef55503460f94c08e32/html5/thumbnails/19.jpg)
Assignment 1 Draw algorithm and flowchart
1. Find area of triangle (area=(1/2)*breadth*height)
2. Convert Celsius to Fahrenheit temperature f = (1.8*c) + 32;
3. Volume of cylinder(V= 3.14*R*R*Height)
4. Find volume of sphere (4/3* 3.14*R*R*R)
5. Find biggest of three numbers.
![Page 20: Algorithm & Flow Charts Presented By Manesh T Course:1090 CS.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ef55503460f94c08e32/html5/thumbnails/20.jpg)
Instructions to students
Study definition well Study different algorithms well Study how to draw flowchart for specific
problems. Workout various assignment problems Approach me for any doubt clarifications
![Page 21: Algorithm & Flow Charts Presented By Manesh T Course:1090 CS.](https://reader035.fdocuments.net/reader035/viewer/2022081513/56649ef55503460f94c08e32/html5/thumbnails/21.jpg)
Control Statements
Decision Making &Branching
Decision Making &Looping
If Statement Switch ConditionalStatement
Simple If
If else Nested if else
If else ladder
For loop
Do while loop
While loop
Jump
Break Continue