Algorithm and flowchart

17
Algorithm and Flowchart 1 Presented by: The Anonymous BSc.CSIT 1 st semester

Transcript of Algorithm and flowchart

Page 1: Algorithm and flowchart

1

Algorithm and Flowchart

Presented by: The AnonymousBSc.CSIT 1st semester

Page 2: Algorithm and flowchart

ContentWhat is algorithm ?Properties of algorithmWhat is flowchart ?Merits of flowchartDemerits of flowchartAlgorithm and Flowchart in CodingReferencesQueries

2

Page 3: Algorithm and flowchart

3

What is an algorithm ?

Named after Persian mathematician Mohammad Al-Khwarizmi

A sequential solution of any problemWritten in human understandable formRequires a clear understanding of the problem

Page 4: Algorithm and flowchart

4

Example:1. Algorithm for sum of two numbers

Step 1: StartStep 2: Enter two numbers in a and bStep 3: Add a and b and store in cStep 4: Display cStep 5: End

Page 5: Algorithm and flowchart

5

2. Algorithm to check whether the input number is even or odd

Step 1: StartStep 2: Enter a number in aStep 3: Check if it is even or odd Step 4: If even print “even” (a mod 2 = 0 )Step 5: Else print “odd”Step 6: End

Page 6: Algorithm and flowchart

6

Properties of algorithm

FinitenessProperly definedInputOutputEffectivenessIndependent to any other programming language

Page 7: Algorithm and flowchart

7

Now moving on to next programming

tool

Page 8: Algorithm and flowchart

8

What is flowchart?

Diagrammatic representation of algorithmAn important programming toolSolving a problem using figuresDifferent figures having different functions

Page 9: Algorithm and flowchart

9

Merits of flowchart

•Easy to explain program logic•Makes coding effective and faster•Effective communication•Different symbols used•Serve as documentation•Easy to detect, locate and remove bugs in a program

Page 10: Algorithm and flowchart

10

Demerits of FlowchartTime consuming and monotonous jobDifficult to maintainOccupies space while documentationTranslation to computer program is difficult

Page 11: Algorithm and flowchart

11

But what might be the symbols used in flowchart?

Page 12: Algorithm and flowchart

12

Flowchart symbolsSymbol Function Description

Start/End Start and end point

Input/output Input and output operations

Processing operation Editing and calculation of data

Decision Check logical condition

Connector Indicates logical flow from one page to another

Direction of logic Direction of flow of logic

Comment Indicates any comments for explanatory notes

Page 13: Algorithm and flowchart

13

Example 1: Flowchart add sum of two numbersSTART

Input a and b

C = a + b

Display c

END

User can enter any two numbers

Page 14: Algorithm and flowchart

14

Example 2: Flowchart to check whether the input number is even or odd

START

Accept a number

Divide it by 2

END

Is remainder = 0 ?

Display odd Display even

YesNo

START

Accept a number

Page 15: Algorithm and flowchart

15

Using Algorithm and Flowchart in CodingCoding

Enter numbers in a and b: 56Displayed c: 11

Page 16: Algorithm and flowchart

16

References:Websites:

google.comwikipedia.comlinkedin.com

External sources:Text book: Fundamentals of computer programming

Page 17: Algorithm and flowchart

17

Queries