Algorithm and flowchart

Post on 11-Apr-2017

137 views 1 download

Transcript of Algorithm and flowchart

1

Algorithm and Flowchart

Presented by: The AnonymousBSc.CSIT 1st semester

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

2

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

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

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

6

Properties of algorithm

FinitenessProperly definedInputOutputEffectivenessIndependent to any other programming language

7

Now moving on to next programming

tool

8

What is flowchart?

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

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

10

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

11

But what might be the symbols used in 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

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

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

15

Using Algorithm and Flowchart in CodingCoding

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

16

References:Websites:

google.comwikipedia.comlinkedin.com

External sources:Text book: Fundamentals of computer programming

17

Queries