Flowcharting and Algorithms
Flowcharting and Algorithms
Algorithms
Flowchart
Use of symbols and phrases to
designate the logic of how a
problem is solve.
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
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
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.
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.