Flowcharting and
Algorithms
Flowchart
Use
of symbols and phrases to
designate the logic of how a
problem is solve.
common method for defining
the logical steps of flow within a
program by using a series of
symbols to identify the basic
Input, Process and Output (IPOs)
function within a program.
two-dimensional representation of an
algorithm; the predefined graphic
symbols of a flowchart are used to
indicate the various operations and the
flow of control.
diagram representing the logical
sequence in which a combination of
steps or preparations is to be
performed. It is a blueprint of the
program.
Algorithm
Algorithm
is a finite set of
instructions that specify a
sequence of operations to be
carried out in order to solve a
specific problem or class of
problems.
Basic Symbols Used in
Flowcharting
Symbols
What it represents
Used to signify the beginning and end
of flowchart
Terminal
Signifies the preparation of data
Used to select initial conditions
Preparation /
Initialization
Used to represent instruction or group
of instructions that will alter or modify
a programs course of execution.
Symbols
Input / Output
What it represents
Shows input and output. Data are to
be read into the computer memory
from an input device or data are to be
passed from the memory to an output
device
Performs any calculations that are to
be done
Processing
Signifies any decision that are to be
done
Decision
Two alternative execution paths are
possible. The path to be followed is
selected during the execution by
testing whether or not the condition
specified within the outlined is fulfilled
Symbols
What it represents
Shows the entry or exit point of the
flowchart
A non-processing symbol used to
connect one part of a flowchart to
On-Page Connector another without drawing flowlines
Conserves space by keeping related
blocks near one another, reduces, the
number of flowlines in complex
programs, and eliminates cross lines
from taking place
Designates entry to or exit from one
page when a flowchart requires more
Off-Page Connector than one page
Symbols
What it represents
Signifies the process that is to be
executed
Flowlines
Basic Control Structures
SEQUENCE
process is executed from one to
another in a straightforward
manner.
Design a flowchart that will accept and display
a number. Write its equivalent algorithms.
Start
Algorithm:
EXAMPLE!!
!!
Step 1. Read in the value of N.
Read N
Print N
End
Step 2. Print the value of N.
Operators Commonly
Used in Flowcharting
Arithmetic Operators
Operators
Meaning
+
*
/
Addition
Subtraction
Multiplication
Division
Relational Operators
Operators
Meaning
=
>
<
<>
Equal
Greater than
Less than
Not Equal
Greater than or Equal
to
Less than or Equal to
Logical Operators
Operators
Meaning
&&
||
!
AND
OR
NOT
Draw a flowchart that will compute and display
the sum and product of two numbers. Write its
equivalent algorithm .
Start
Sum = 0
Product
=0
Read
A,B
Sum = A+ B
Product =
A*B
Algorithm:
Step 1. Initialize Sum and Product into 0.
Step 2. Read in the values of A and B.
Step 3. Compute Sum by adding A and B
then compute Product by multiplying A
and B.
Step 4. Print the computed value of Sum
and Product.
Print
Sum,
Product
End
Construct a flowchart that will convert an
inputted number in Fahrenheit to its
equivalent measure in Celsius.
Start
Formula :
C=(5/9)x(F32)
Step 1. Initialize Celsius into 0.
Step 2. Read in the value of
Fahrenheit.
Celsius
=0
Step 3. Compute the value of
Celsius.
Step 4. Print the computed value
of Celsius.
Read
Fahrenhe
it
Celsius =(5/9)x(F32)
Algorithm:
Print
Celsius
End
Assignment (Flowchart and
Algorithm)
Construct a flowchart that will compute and print
the sum and average of 3 numbers.
Answer
Draw a flowchart that will compute and display
the area of a rectangle.
Answer
Construct a flowchart that will convert and
display an inputted number in inches(in.) to its
equivalent number in feet.
Answer
Quiz
Selection (If then else)
- A choice is provided between two
alternatives
A
T
F
B
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 in the values of A and B.
EXAMPLE!!
!!
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.
A>B
Print A,
Higher
F
Print B,
Higher
End
Draw a chart that will input a grade of a student and determine
whether the grade is passed or failed. Print the name , grade
and remark of the student. Write its equivalent algorithm
Algorithm:
Start
Step 1. Initialize name and remarks into blanks.
Step 2. Read in values for Grade and Name.
Name=
Remarks=
Step 3. Test if Grade is greater than or equal to 60.
Step 4. If Grade is greater than or equal to 60,
remark is Passed. However, if Grade is below
60, remark is Failed.
Read
Name,
Grade
Grade
60
Step 5. Print the name, grade, and remarks.
Remarks =
Passed
F
Remarks =
Failed
Print
Name,
Grade,
Remarks
End
DEI Manufacturing Company plans to
give a year-end bonus to each of its
employee. Draw a flowchart which will
compute the bonus of an employee.
Consider the following conditions: If the
employees monthly salary is less than
2,000.00, the bonus is 50% of the
salary; for employees with the salaries
greater than 2,000.00, the bonus is
1,500.00. Print the name and the
corresponding bonus for each employee.
Write each equivalent algorithms.
ANSWER
Algorithm:
Start
Step 1. Initialize bonus to 0.
Step 2. Read in employee's name and salary.
Step 3. Test if employees salary is less than 2,000.
Bonus = 0
Step 4. If salary < 2,000 then Bonus= salary * 50%
else
Bonus = 1,500.
Read
Name,
Salary
Salary
<
2,000
Step 5. Print the employees name and bonus.
Bonus = 1,500
T
Bonus =
0.5*Salary
Print
Name,
Bonus
End
Using On-page connector
Start
Bonus = 0
Bonus = 1,500
Bonus =
0.5*Salary
Read
Name,
Salary
Salary
<
2,000
Print
Name,
Bonus
End
Assignment
Construct a flowchart that will accept the evaluation
score of a faculty and determine its equivalent
remarks. Print the name of the faculty and the
remarks obtained. Remarks (Rem) are based on the
following criteria: Write its equivalent algorithms.
4.50
4.00
3.50
3.00
2.99
5.00
4.49
3.99
3.49
below
Answer
Outstanding
Very Satisfactory
Satisfactory
Needs Improvement
Poor
Quiz
Repetition (Looping)
Do while this structure
provides for the repetitive
execution of an operation or
routine while the condition is
true. The condition is evaluated
before executing any process
statement. As long as the
condition is true, the process is
executed, otherwise, control
flows out of the structure.
C
T
Construct a flowchart that will count from 1 to 10 and
print each number counted using the do-while-repetition
structure. Write its equivalent algorithm.
Algorithm:
Start
Step 1. Initialize the value of C to 0.
Step 2. Test if the C is less than 10,.
Step 3. If C is less than 10, add 1 to
the value of C, print the value then
go back to Step 2. However, if C is
greater than 10, stop processing.
C= 0
C<
10
C=C+1
Print C
End
The initial value of the radius (R) of a circle is equal to 1 unit and each
succeeding radius is 1 unit greater than the value before it. Draw a
flowchart to compute the Area of a circle starting with R = 1 to R = 5,
then print each radius and the corresponding area of a circle.
Start
Algorithm:
Pi =
3.14
R=1
Step 2. Compute the area by multiplying Pi to
the square of R.
Step 1. Initialize the value of R to 1 and the
value of Pi to 3.14
Step 3. Print the value of R and the computed
Area.
Area = Pi * R *
R
Print R,
Area
R= R + 1
Step 4. Increment the value of R by 1.
Step 5. Test R if less than or equal to 5.
Step6. If R is less than or equal to 5, loop back
and repeat steps 2. to 5. However, if R is
greater than 5, stop processing.
T
R5
End
Assignment
1.
2.
3.
Draw a flowchart that will read and print
the names and individual score of 50
students for a particular examination.
Also, determine the average score and
print it.
Design a flowchart that will generate the
sum and product of 20 input numbers.
Construct a flowchart that will compute
the evaluation rating of a teacher given
by 32 students. Print the average.
Algorithm:
Step1. Initialize Rem into space or blanks.
Step2. Read in the values of Name and
Score.
Step3. Test the score if it is greater than
or equal to 4.50.
Step4. If the score is greater than or
equal to 4.50, Rem is Outstanding.
However, if the score is less than 4.50,
do step 5.
Step5. Test the score if it is greater than
or equal to 4.00.
Step6. If the score is greater than or
equal to 4.00, Rem is Very
Satisfactory. However, if the score is
less than 4.00, do step 7.
Step7. Test the score if it is greater than
or equal to 3.50.
Step8. If the score is greater than or
equal to 3.50, Rem is Satisfactory.
However, if the score is less than 3.50,
do step 9.
Step9. Test the score if its is greater than
or equal to 3.00.
Step10. If the score is greater than or
equal to 3.00, Rem is Needs
Improvement. However, if the score is
less than 3.00, Rem is Poor.
Step11. Print the name and Rem.
SEQUENCE
1.
2.
3.
4.
Draw a flowchart that accepts a number in kilowatts
then display its equivalent number in watts. (1 watt =
0.0001 kw).
Draw flowchart that accepts a value for radius (R)
and compute the corresponding area of a circle. Print
the value of the radius and the computed area. (Area
= x R).
Construct a flowchart that accepts a number in
square meter (m) and display its equivalent number
in hectares (has). 1000 m = 1 ha.
Read 2 records in a computer. The first record will
contain unit price and the second record will contain
quantity. Draw a flowchart that will compute and
display the amount by multiplying unit price and
quantity.
SELECTION
1.
2.
Given two numbers x and y, draw a
flowchart to determine the difference
between x and y. If x - y is negative,
compute r = x + y; if x y is zero,
compute r = 2x + 2y; and if x y is
positive, compute r = x * y. Print the
values of x, y, and r.
Construct a flowchart that asks for the
amount purchased by the customer. If the
customer purchases more than 2,000
then a 5% discount is given. Display the
net amount to be paid by the costumer.