You are on page 1of 36

Flowcharting and

Algorithms
Flowchart
Use of symbols and phrases to
designate the logic of how a
problem is solve.

A 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 (IPO’s)
function within a program.
A 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.

A 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 / •Used to represent instruction or group


Initialization of instructions that will alter or modify
a program’s course of execution.
Symbols 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
Input / Output 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

• Two alternative execution paths are


possible. The path to be followed is
Decision 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.
Step 2. Print the value of N.
Read N

!!
Print N

End
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 .
Algorithm:
Start

Step 1. Initialize Sum and Product into 0.


Sum = 0 Step 2. Read in the values of A and B.
Product
=0 Step 3. Compute Sum by adding A and B
then compute Product by multiplying A
and B.
Read Step 4. Print the computed value of Sum
A,B and Product.

Sum = A+ B Print
Product = Sum, End
A*B Product
Construct a flowchart that will convert an
inputted number in Fahrenheit to its
equivalent measure in Celsius.
Formula :
C=(5/9)x(F- Algorithm:
Start
32) 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
Read of Celsius.
Fahrenhe
it

Celsius =(5/9)x(F- Print


32) 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.

Start Algorithm:
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.
Input
However, if A is less than B, B is
A,B
higher.
Step 4. Print the number and the remark

!!
“Higher”.

T Print A,
A>B ”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

Start Algorithm:
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
Read 60, remark is “Failed”.
Name,
Grade Step 5. Print the name, grade, and remarks.

Grade T Remarks =
≥ 60 “Passed”

F
Print
Remarks = Name,
“Failed” Grade, End
Remarks
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
employee’s 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 employee’s salary is less than 2,000.
Bonus = 0
Step 4. If salary < 2,000 then Bonus= salary * 50%
else
Read Bonus = 1,500.
Name, Step 5. Print the employee’s name and bonus.
Salary

Salary F
< Bonus = 1,500
2,000

T
Print
Bonus =
0.5*Salary
Name, End
Bonus
Using On-page connector
Start A B

Bonus =
Bonus = 0 Bonus = 1,500
0.5*Salary

Read
Print
Name,
Name,
Salary
Bonus

F Salary T End
A < B
2,000
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 – 5.00 – Outstanding


4.00 – 4.49 – Very Satisfactory
3.50 – 3.99 – Satisfactory
3.00 – 3.49 – Needs Improvement
2.99 below – Poor

Answer 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.
F
C

A
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
C= 0 the value of C, print the value then
go back to Step 2. However, if C is
greater than 10, stop processing.

C<
10 End

C=C+1

Print C
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.

Algorithm:
Start
Step 1. Initialize the value of R to 1 and the
value of Pi to 3.14
Pi = Step 2. Compute the area by multiplying Pi to
3.14 the square of R.
R=1 Step 3. Print the value of R and the computed
Area.
Area = Pi * R * Step 4. Increment the value of R by 1.
R 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
Print R, greater than 5, stop processing.
Area T

F
R= R + 1 R≤5 End
Assignment
1. 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.
2. Design a flowchart that will generate the
sum and product of 20 input numbers.
3. 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. Draw a flowchart that accepts a number in kilowatts
then display its equivalent number in watts. (1 watt =
0.0001 kw).
2. 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²).
3. Construct a flowchart that accepts a number in
square meter (m²) and display its equivalent number
in hectares (has). 1000 m² = 1 ha.
4. 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. 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.
2. 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.

You might also like