Algorithm and Flowcharting
Algorithm and Flowcharting
Program Flowcharts
Depicts the detailed logical flow of process in a program.
System Flowcharts
Shows the logic flow of data from one source to another.
Divided into functions of departments or personnel.
Symbols are used to represent documents used and
operations undertaken.
Highlights excessive information flow, duplication of
information stored in different locations and reasons for
delay of transactions.
Flowcharting
Basic Flowcharting Symbols
Terminal block
On-page Connector
Process symbol
Off-page Connector
Input/Output block
Initialization symbol
Terminal
OVAL - used to signify the beginning
and end of flowchart
START
Flowcharting
Basic Flowcharting Symbols
Preparation/Initialization
Input/Output
Parallelogram
-shows input and output.
Data are to be read into the
computer memory from an
input device or data are to
Read A be passed from the memory
Print A to an output device.
Flowcharting
Basic Flowcharting Symbols
Process/Processing
Rectangle
-performs any calculations hat
are to be done.
Sum = A+B
Flowcharting
Basic Flowcharting Symbols
Decision
On-page Connector
Off-page Connector
Flowlines
standard convention.
Input operation are represented in a parallelogram. A
NAME = “WASHINGTON”
Logical or Boolean Variables
A special type of variable that can only have two values - TRUE or
FALSE.
Flowcharting
Arithmetic Operators and Mathematical Statements
Addition (+)
Subtraction (-)
Multiplication (*)
Division (/)
Modulus (%)
x=x+1
sum = a + b
Flowcharting
Constants
A constant is a value that never changes during the
execution of the program.
Constants can be any type-numeric, alphabetic or
special symbols.
Like variable, constants can be named. The computer
sets up a specific memory location to hold the value of
the constant.
During the execution of the program, the constant is
referred to by name. Once the constant is given a
value, it cannot be changed during the execution of
the program.
Flowcharting
Relational Operator
A relational operator compares two values and
determines the relationship between them.
START
Algorithm:
Step 1: Read in the value of N.
READ N
Step 2: Print the value of N.
PRINT N
END
Draw a flowchart that will compute and display the sum and
product of two numbers. Write its equivalent algorithm.
START Algorithm:
Step 1: Initialize Sum and Product
into 0.
Sum = 0 Step 2: Read in the values of A and
Product = 0 B.
Step 3: Compute the sum by
adding A and B then compute the
Read A,B
product by multiplying A and B.
Step 4: Print the computed value of
Sum and Product.
START Algorithm:
Step 1: Initialize Celsius into 0.
Step 2: Read in the value of
Celsius=0 Fahrenheit.
Step 3: Compute the value of
Celsius.
Read Fah Step 4: Print the computed value of
Celsius.
Celsius=(5/9)*
(Fah-32) Print
END
Celsius
Draw a flowchart that will input values for A and B. Compare two
values inputted and print which of the values is higher including the
remark “Higher”. Write its equivalent algorithm.
Algorithm:
START Step 1: Read the values of A and B.
Step 2: Test if A is greater than B.
Step 3: If A is greater than B, A is higher.
However, if A is less than B, B is higher.
Input A,B Step 4: Print the number and the remark
“Higher”
T
A>B Print A,
“Higher”
F
Print B, END
“Higher”
Draw a flowchart that will input grade of student and determine
whether the grade is passed or failed. Print the name, grade and
remarks of student. Write its equivalent algorithm.
START Algorithm:
Step 1: Initialize name and remarks into blanks.
Step 2: Read in values for Grade and Name.
Step 3: Test if Grade is greater than or equal to 60.
Step 4: If Grade is greater than or equal to 60,
Name=“ “ remark is “Passed”. However, if Grade is below
Remarks = “ “ 60, remark is “Failed”.
Step 5: Print the name, grade and remarks.
Read Name,
Grade
If Grade Remarks =
>60 “Passed”