Vous êtes sur la page 1sur 17

Algorithm and Flowcharting

Prepared by: Ms. Roxanne A. Pagaduan


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.
• Step by step process to solve a problem.
• A detailed sequence of steps that is needed to
solve a particular problem.
Flowchart
• A visual representations of an algorithm.
• Use of symbols and phrases to designate the
logic of how a problem is solved.
Types of Flowcharting

1. Program Flowchart
• Describes graphically in detail the logical
operations and steps within a program and
the sequence in which these steps are to be
executed for the transformation of data to
produce the needed output.
Program flowchart
Types of Flowcharting
2. System Flowchart
• Is a graphic representation of the procedures
involved in converting data on input media to
data in output form. The emphasis is on the
media used and the work stations through
which the data passes.
System Flowchart
NAME FUNCTION SYMBOL
Terminal Symbol Beginning and end of a procedure or a
(oval) program

Initialization Box Preparation of initial data or values for a


(Hexagon) variable

Input/Output Box Storing , reading of data and displaying the


(Parallelogram) output

Processing Box Computation or any processing done in a


(Rectangle) program

Decision Box Signifies that a condition have to be


Diamond) evaluated and a selection must be made

Flowlines Signify the order in which the actions are


(arrowheads) performed, it tells the direction of the flow
of operation

Connectors Connects a flowchart within the page (On


Page Connector)
Connects a flowchart at the next page (Off
Page Connector)
Flowcharting Techniques

1. Sequential Structures – is used when


the program statement are to be
executed one after the other in a
given sequence.
Format:
Flowcharting Techniques
2. Selection Structures – it begins with a single flow line
entering a decision symbol. The decision symbol represents a
test. It is based on the results of the test, either the logic
path on the right is taken or the logic path on the left is
taken. Both logic pat come back together at the bottom of
the structure and a single flow line exit the structure.
Format: T
F
Flowcharting Techniques
3. Iteration Structures – it begins with a single
flow line entering a decision symbol. However,
an iteration structure there is a potential
looping. The logic steps inside the loop will be
performed repeatedly while the condition is
true. When the condition becomes false, the
loop exited. If the condition is false initially, the
logic step inside the loop will not be executed at
all.
• Format:
Example A.
The RAA Clothing Company plans to give a year-end bonus to each of its employees. Draw
a flowchart which will compute the bonus of an employee. Consider the following criteria:
1. If the employee’s monthly salary is less than P10,000.00, the bonus is 50% of
the salary;
2. For employee’s with salaries greater than P10,000.00, the bonus is P5,000.00
Print out the name and corresponding bonus of the employee.
ALGORITHM
1. Read in the employee’s name
and salary.
2. Test if the employee’s salary is
less than P10,000.00.
3. If the salary is < P10,000.00,
bonus = 50% of the salary
If the salary is > P10,000.00,
bonus = P5,000.00
4. Print out the employee’s name
and bonus.
• FLOWCHART
Start

NAME = “”
SALARY = 0
BONUS = 0

READ NAME,
SALARY

A
IS
N Yes
SALARY <= BONUS = PRINT NAME,
P10,000.00 ? BONUS
SALARY * .50

No
BONUS =
P5,000.00 End

A
Example B.
1. Draw a flowchart that will compute and display the sum and
product of two numbers. Write its equivalent algorithm.

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.
Flowchart
Start

Sum = 0
Product = 0

Read A, B

Sum = A+B
Product = A*B

Print Sum,
Product End
Example C.
1. Draw a flowchart that will count from 1 to 10 and print each
number counted using the iteration repetition structure.
Write its equivalent algorithm.
Algorithm.
Step 1. Initialize the value of C to 0.
Step 2. Test if 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.
• Flowchart
Start

C=0

F
C < 10 End

T
C=C+1

Print C

Vous aimerez peut-être aussi