0% found this document useful (0 votes)
35 views27 pages

Algorith Flowchart

The document discusses algorithms, flowcharts, and decision structures. It provides examples of writing algorithms and drawing flowcharts to calculate a student's grade, sum even numbers, and determine if a grade is passed or failed. Decision symbols and IF/THEN statements are used in flowcharts. Common flowchart symbols and relational operators are also defined.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views27 pages

Algorith Flowchart

The document discusses algorithms, flowcharts, and decision structures. It provides examples of writing algorithms and drawing flowcharts to calculate a student's grade, sum even numbers, and determine if a grade is passed or failed. Decision symbols and IF/THEN statements are used in flowcharts. Common flowchart symbols and relational operators are also defined.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

COMP.

1 : COMPUTER FUNDAMENTALS AND


PROGRAMMING

ALGORITHMS AND
FLOWCHARTS
by: eestrellado2022
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

◼ Create a step by step instructions (detailed


algorithm) that is very close to a computer
language.

ALGORITHM – self contained step by step set of


operations to be performed by computer.
The Flowchart
◼ A graphical representation of the
sequence of operations in an information
system or program.
◼ Information system flowcharts shows how
data flow from source documents through
the computer to final distribution to users.
◼ Program flowcharts show the sequence of
instructions in a single program or
subroutine using different symbols.
The Flowchart
 shows logic of an algorithm
 emphasizes individual steps and their
interconnections (using symbols & control
flow from one action to the next)
Flowchart Symbols
Symbols NAME Description

OVAL TERMINAL/ Denotes the beginning


TERMINATOR and end of the program

Parallelogram Input/output Denotes an input and


output data

Rectangle Process Denotes a process to be


carried out

Diamond Decision Symbol Denotes a decision to


be made (e.g. IF –
THEN-ELSE Statement
Arrow Flow lines Denotes the direction
or logic flow of the
program
EXAMPLE
IN WRITING AN ALGORITHM
AND DRAWING A
FLOWCHART
Writing an Algorithm & draw a
flowchart
◼ Example 1: Write an algorithm and draw a
flowchart to determine a student’s final
grade. The final grade is calculated as the
average of two exams: midterm and final
exam.
FLOWCHART
ALGORITHM

◼ 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, to compute the sum of three
even numbers (14, 20, 34).
ALGORITHM FLOWCHART

◼ Step 1: Input X, Y, Z

◼ Step 2: SUM = X+Y+Z

◼ Step 3: PRINT/DISPLAY SUM

or
◼ Step 1: Input 14, 20, 34

◼ Step 2: SUM = 14+20+34

◼ Step 3: PRINT/DISPLAY
◼ SUM = 68
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, Q1,Q3, Q4
◼ In this example we are going to validate
the result using IF Function or IF
statement , so decision symbol will be use.
◼ The IF function is one of the most popular
functions in Excel, and it allows you to
make logical comparisons between a
value and what you expect.
 An IF statement can have two results. The
first result is if your comparison is True, the
second if your comparison is False.
◼ IF statement/logical statement is defined
as a function which “checks whether a
condition is met, returns one value if True
and another value if False”.
◼ IF, THEN, ELSE. If something is true,
then do this, else/otherwise do that.

For example, if it’s raining, then close the


windows, else/otherwise leave the windows
open.
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, Q1,Q3, Q4 or L,M,N,O
Algorithm
◼ Detailed Algorithm
◼ Step 1: Input L, M, N, O
Step 2: FG = (L + M + N + O) /4
Step 3: If (GRADE < 75) then
Print “FAILED”
else
Print “PASSED”
end If
Example Flowchart
START

Input
L, M, N, O

FG = (L + M + N + O) /4

N IF Y
GRADE<75

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) (FALSE) 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

FALSE IF
GRADE<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) (TRUE) 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 TRUE
GRADE<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 N
is
A>B

Print Print
A 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

< Less than

= Equal to

 Greater than or equal to

 Less than or equal to

 Not equal to
References:
◼ http://www.yspuniversity.ac.in/cic/algorithm-manual.pdf

◼ https://byjus.com/maths/even-
numbers/#:~:text=What%20is%20an%20Even%20Number,%2C%2
012%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/

You might also like