Flowchart PDF
Flowchart PDF
FLOWCHARTS
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
Pseudocode:
• 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”
PSEUDOCODE & ALGORITHM
• 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”
endif
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
START
Step 1: Input M1,M2,M3,M4
Step 2: GRADE (M1+M2+M3+M4)/4
Input
M1,M2,M3,M4
Step 3: if (GRADE <50) then
Print “FAIL”
else
GRADE(M1+M2+M3+M4)/4 Print “PASS”
endif
N IS Y
GRADE<5
0
PRINT PRINT
“PASS” “FAIL”
STOP
EXAMPLE 2
Algorithm START
STOP
EXAMPLE 3
• Step 2: AL x W
W, L
Print
A
STOP
EXAMPLE 4
Pseudocode:
• Input the coefficients (a, b, c) of the quadratic equation
• Calculate d
• Calculate x1
• Calculate x2
• Print x1 and x2
EXAMPLE 4
START
• Algorithm:
Input
• Step 1: Input a, b, c a, b, c
b b 4 a c
• Step 2: d sqrt ( ) d sqrt(b x b – 4 x a x c)
• Step 4: x2 (–b – d) / (2 x a)
X2 (–b – d) / (2 x a)
• Step 5: Print x1, x2
Print
x1 ,x2
STOP
DECISION STRUCTURES
Y N
is
A>B
Print A Print B
IF–THEN–ELSE STRUCTURE
Relational Operators
Operator Description
> Greater than
< Less than
= Equal to
Greater than or equal to
Less than or equal to
Not equal to
EXAMPLE 5
Input
VALUE1,VALUE2
Y is
N
VALUE1>VALUE2
Print
“The largest value is”, MAX
STOP
NESTED IFS