Upcoming SlideShare
×

# Algorithms&flowcharts

949 views

Published on

Algorithms and flowcharts

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total views
949
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
29
0
Likes
0
Embeds 0
No embeds

No notes for slide

### Algorithms&flowcharts

1. 1. ALGORITHMS &FLOWCHARTS Ashwin Anand V
2. 2. AlgorithmAn Algorithm is just a detailed sequence of simplesteps that are needed to solve a problemFlowchartA Flowchart is the graphical representation ofan Algorithm.
3. 3. Steps to create an algorithm• First produce a general algorithm• Refine the algorithm successively to get step by step detailed algorithm that is very close to a computer language.• Pseudo code is an artificial and informal language that helps programmers develop algorithms. Pseudo code is very similar to everyday English.
4. 4. ExampleWrite an algorithm to determine a student’s final grade and indicatewhether it is passing or failing. The final grade is calculated as theaverage of four marks. Pseudo code: • Input a set of 4 marks • Calculate their average by summing and dividing by 4 • if average is below 50 Print “FAIL” else Print “PASS”
5. 5. Detailed Algorithm Step 1: Input M1,M2,M3,M4 Step 2: GRADE (M1+M2+M3+M4)/4 Step 3: if (GRADE < 50) then Print “FAIL” else Print “PASS” end
6. 6. Flowchart Symbols BasicName Symbol Use in FlowchartOval Denotes the beginning or end of the programParallelogram Denotes an input operationRectangle Denotes a process to be carried out e.g. addition, subtraction, division etc.Diamond Denotes a decision (or branch) to be made. The program should continue along one of two routes. (e.g. IF/THEN/ELSE)Hybrid Denotes an output operationFlow line Denotes the direction of logic flow in the program
7. 7. Example START Step 1: Input Input M1,M2,M3,M4 M1,M2,M3,M4 Step 2: GRADE (M1+M2+M3+M4)/4 GRADE (M1+M2+M3+M4)/4 Step 3: if (GRADE <50) then Print “FAIL” N Y IS GRADE<50 else Print “PASS”PRINT PRINT end“PASS” “FAIL” STOP
8. 8. Example• Write an algorithm that reads two values, determines the largest value and prints the largest value with an identifying message.ALGORITHMStep 1: Input A,BStep 2: if (A> B) then MAX A else MAX B endStep 3: Print “The largest value is”, MAX
9. 9. • 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
10. 10. START Input A,B Y is N A>BMAX A MAX B Print “The largest value is”, MAX STOP
11. 11. Thank you
12. 12. Disclaimer: This presentation is prepared by trainees of baabtra asa part of mentoring program. This is not official document ofbaabtra – Mentoring Partnerbaabtra – Mentoring Partner is the mentoring division of baabte System Technologies Pvt. Ltd.