0% found this document useful (0 votes)
143 views

Flowcharting and Algorithms

The document discusses flowcharting and algorithms. It defines a flowchart as a diagram representing the logical sequence of steps to solve a problem. An algorithm is defined as a finite set of instructions that specify the sequence of operations to solve a problem. The document then discusses basic flowchart symbols such as terminals, preparation, input/output, processing, and decision. It also covers basic control structures like sequence and selection. Finally, it introduces repetition structures like do-while loops.

Uploaded by

Roces Awyi
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
143 views

Flowcharting and Algorithms

The document discusses flowcharting and algorithms. It defines a flowchart as a diagram representing the logical sequence of steps to solve a problem. An algorithm is defined as a finite set of instructions that specify the sequence of operations to solve a problem. The document then discusses basic flowchart symbols such as terminals, preparation, input/output, processing, and decision. It also covers basic control structures like sequence and selection. Finally, it introduces repetition structures like do-while loops.

Uploaded by

Roces Awyi
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 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 of


Initialization 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 passed from the memory to an
Input / Output 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 selected during the
execution by testing whether or not the condition
Decision 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 another without drawing
flowlines
On-Page Connector
• 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 than one page
Off-Page Connector
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:

Step 1. Read in the value of N.


Step 2. Print the value of N.
Read N

EXAMPLE!!!!
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.


Step 2. Read in the values of A and B.
Sum = 0
Product =0 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.
Read A,B

Sum = A+ B Print Sum,


Product End
Product = A*B
Construct a flowchart that will convert an inputted
number in Fahrenheit to its equivalent measure in
Celsius.
Formula : Algorithm:
Start C=(5/9)x(F-32)
Step 1. Initialize Celsius into 0.
Step 2. Read in the value of Fahrenheit.
Step 3. Compute the value of Celsius.
Celsius = 0
Step 4. Print the computed value of
Celsius.

Read
Fahrenheit

Print
Celsius =(5/9)x(F-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.
Step 2. Test if A is greater than B.
Step 3. If A is greater than B, A is higher. However,
Input
if A is less than B, B is higher.

EXAMPLE!!!!
A,B
Step 4. Print the number and the remark “Higher”.

T
Print A,
A>B ”Higher”

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:
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, remark is
“Passed”. However, if Grade is below 60, remark is
“Failed”.
Step 5. Print the name, grade, and remarks.

F
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
Bonus = 1,500.
Read Name,
Salary Step 5. Print the employee’s name and bonus.

Salary F
Bonus = 1,500
< 2,000

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

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

Read Name,
Print Name,
Salary
Bonus

F Salary T End
A < 2,000 B
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 the value of
C= 0 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.

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