Professional Documents
Culture Documents
ALGORITHMS AND
FLOWCHARTS
by: eestrellado2024
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 using suitable programming
languages
Steps in Problem Solving
Step 1: Input M, F
Step 2: FG = (M + F)/2
Step 3: PRINT/DISPLAY FG
Note: M = Midterm
F = Finals
2 = two terms
ALGORITHM FLOWCHART
Step 1: Input M, F
Step 2: FG = (M + F)/2
Step 3: PRINT/DISPLAY FG
Note: M = Midterm
F = Finals
2 = two terms
Writing an Algorithm & draw a
flowchart
Example 2: Write an algorithm and draw a
flowchart, that will compute the sum of
three even numbers.
Let X = 1st even number
Step 3: PRINT/DISPLAY
SUM = 68
ALGORITHM FLOWCHART
START
Step 1: Input X=14, Y=20, Z=34
Step 3: PRINT/DISPLAY
SUM = 68
SUM = 14+20+34
SUM = 68
END
Problem #3
(WITH DECISION SYMBOL)
Example 3: Write an algorithm and draw a
flowchart to determine a student’s final
grade and indicate a remarks whether it is
“PASSED” or “FAILED” grade. The final
grade is calculated as the average of four
marks.
EXAMPLE: Find the average of :
Q1, Q2,Q3, Q4
In this example we are going to validate
the result using IF Function or IF
statement , so decision symbol will be use.
An IF statement can have two results. The
first result is if your comparison is True, the
second if your comparison is False.
Input
Q1=80,Q2=83,Q3=85,Q4=90
A = (80+83+85+90) /4
Display A= 84.5
Y IF N
A >74
PRINT PRINT
“PASSED” “FAILED”
END
Algorithm
Detailed Algorithm
Step 1: Input L=80, M=87, N=85, O=90
Step 2: FG = (80+87+85+90) /4
FG = 85.5
Step 3: If (GRADE < 75) (NO) then
Print “FAILED”
else
Print “PASSED”
end If
Example Flowchart
START
Input
L=80, M=87, N=85, O=90
FG = (80+87+85+90) /4
FG = 85.5
NO IF
FG<75
PRINT
“PASSED”
END
Algorithm
Detailed Algorithm
Step 1: Input L=67, M=67, N=65, O=60
Step 2: FG = (67+67+65+60) /4
FG = 64.75
Step 3: If (GRADE < 75) (YES) then
Print “FAILED”
else
Print “PASSED”
end If
Example Flowchart
START
Input
L=67, M=67, N=65, O=60
FG = (67+67+65+60) /4
FG = 64.75
IF YES
FG<75
PRINT
“FAILED”
END
DECISION STRUCTURES
The expression A>B or 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 to the right, display/print the result for
the value of A and display the “remarks”
if A>B is false (if A is not greater than B) we
take the action to the right, display/print the
result for the value of B and display the
“remarks”
DECISION STRUCTURES
Structure:
Y is
N
A>B
Print A Print B
IF–THEN–ELSE STRUCTURE
The structure is as follows
If condition is TRUE display “remarks”
else
FALSE display “remarks”
endif
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
endif
Relational Operators
Operator Description
> Greater than
= Equal to
Not equal to
Assignment : 4 Problems
Write the algorithm and
graphical representation using
flowchart symbols
Your answer should be in MS
Excel
Ass:Write an algorithm and
draw a flowchart: that will
compute the volume of a sphere
References:
http://www.yspuniversity.ac.in/cic/algorithm-manual.pdf
https://byjus.com/maths/even-numbers/#:~:text=What%20is%20an
%20Even%20Number,%2C%2012%2C%2014%2C%2016.
https://corporatefinanceinstitute.com/resources/excel/study/excel-if-
statement/#:~:text=The%20IF%20statement%20is%20a,of%20code
%20evaluates%20to%20FALSE.
https://engineerstutor.com/2020/10/08/solved-assignment-problems-
algorithms-and-flowcharts/