Algorithms and Flowcharts: Presented by
Algorithms and Flowcharts: Presented by
FLOWCHARTS
PRESENTED BY:
MANJARI AGRAWAL
HIMANI ARORA
GEETA JAGWANI
ALGORITHMS AND FLOWCHARTS
A typical programming task can be divided into
two phases:
Problem solving phase
produce an ordered sequence of steps that describe
solution of problem
this sequence of steps is called an algorithm
Implementation phase
implement the program in some programming
language
Steps in Problem Solving
An algorithm is a finite set of instructions that, if
followed, accomplishes a particular task. In addition,
all algorithms must satisfy the following criteria:
Input: zero or more quantities are externally supplied.
Output: at least one quantity is produced.
Definiteness: each is instruction is clear and
unambiguous.
Finiteness: the algorithm terminates after a finite number
of steps.
Effectiveness: each in instruction must be very basic.
Algorithm
Example 1: A program is required to read
three numbers, add them together and print
their total.
Algorithm
Detailed Algorithm
Step 1: Input M1,M2,M3
Step 2: GRADE M1+M2+M3
Step 3: Print GRADE
The Flowchart
A Flowchart
shows logic of an algorithm
emphasizes individual steps and their
interconnections
e.g. control flow from one action to the next
Flowchart Symbols
Basic
Name Symbol Use in Flowchart
Print total
Stop
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
DECISION STRUCTURES
Y N
is
A>B
Print Print
A B
IF–THEN–ELSE STRUCTURE
The structure is as follows
If condition then
true alternative
else
false alternative
end if
IF–THEN–ELSE STRUCTURE
The algorithm for the flowchart is as
follows:
If A>B then
Y N
print A is
A>B
else
print B Print
A
Print
B
end if
Relational Operators
Relational Operators
Operator Description
> Greater than
< Less than
= Equal to
Greater than or equal to
Less than or equal to
Not equal to
Example 2
Write an algorithm that reads two values, determines the
largest value and prints the largest value with an
identifying message.
ALGORITHM
Step 1: Input VALUE1, VALUE2
Step 2: if (VALUE1 > VALUE2) then
MAX VALUE1
else
MAX VALUE2
end if
Step 3: Print “The largest value is”, MAX
Example 2
START
Input
VALUE1,VALUE2
Y is N
VALUE1>VALUE2
Print
“The largest value is”,
MAX
STOP