Sei sulla pagina 1di 14

ALGORITHMS AND

FLOWCHARTING
ALGORITHM DEFINED
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.
Harold is standing outside facing a park bench.
The bench is two steps away from Harold. Write the
instructions that direct Harold to sit down on the bench.
Harold is standing outside facing a park bench. The bench is two
steps away from Harold. Write the instructions that direct Harold to sit
down on the bench.

1. Walk forward
2. Walk forward
3. Turn left 90 degrees ALGORITHM
4. Turn left 90 degrees
5. Sit down on the bench
Harold is standing outside facing a park bench. The
bench is two steps away from Harold. Harold’s cat Ginger
may be on the bench. Write the instructions that direct
Harold to gently shove Ginger off the bench (if necessary)
and then sit down on the bench
1. Walk forward
2. Walk forward
3. If Ginger is on the bench
gently shove Ginger off the bench
end if
4. Turn left 90 degrees
5. Turn left 90 degrees
6. Sit down on the bench
Write an algorithm to find the
perimeter and area of a rectangle.
1. Get the length of the rectangle.
2. Get the width of the rectangle.
3. Find the perimeter using the following
equation:
perimeter = 2 x (length + width)
4. Find the area using the following equation:
area = length x width
FLOWCHART DEFINED
 Use of symbols and phrases to designate the logic of how
a problem is solved.

 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 diagram representing the logical sequence in which a


combination of steps or operations is to be performed. It is
a blueprint of the program.
BASIC SYMBOLS USED IN
FLOWCHARTING
Symbols What it represents
Used to signify the
beginning and end of
flowchart.
TERMINAL
Symbols What it represents
• Signifies the
preparation of data
• Used to select initial
conditions
• Used to represent
PREPARATION / instructions or group of
INITIALIZATION
instructions that will
alter or modify a
program’s course of
execution.
Symbols What it represents
• Shows input and
output
INPUT / OUTPUT

• Performs any
calculations that are
PROCESSING to be done.
• Signifies any decision
that are to be done

DECISION
Symbols What it represents
• Shows the entry or exit
point of the flowchart
• A non-processing symbol
used to connect one part
ON-PAGE CONNECTOR of a flowchart to another
without drawing flow lines

• Designates entry to or
exit from one page
when a flowchart
OFF-PAGE CONNECTOR
requires more than
one page
Examples Start

 Design a Algorithm:
flowchart that
Read N Step 1. Read in
will accept the value of N
and display a
Step2. Print the value
number. Write of N
its equivalent Print N
algorithms

End
 Draw a flowchart that will
Start
compute and display the sum
and product of two numbers.
Sum = 0
Write the equivalent algorithm
Product = 0 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
Read A,B Product by multiplying A and B
Step 4. Print the computed value of Sum and Product

Sum = A+ B Print Sum,


Product = A* B Product End

Potrebbero piacerti anche