Problem Solving
Pseudocode (Sequence) and Flowcharts
Pseudocode – Layout of a Sequence
Algorithm
START
Declare variable(s)
Prompt statements
Input statements
Assignment statements
Output statements
STOP
Sequence Example
• Write a pseudocode algorithm that accepts
two numbers, calculates the sum and product
and outputs the results.
Sequence Example (continued)
START
Declare num1, num2, Sum, Product as integer
Write “Enter two numbers”
Read num1, num2
Sum num1 + num2
Product num1 * num2
Write Sum, Product
Write “The sum is”, Sum
Write “The product is”, Product
Write “The sum is”, Sum, “and ”, “the product is”, Product
STOP
flowcharts
A flowchart is a diagram that illustrates by means of specialized symbols
and flow lines how events are sequenced by time and order. A flowchart is
an algorithm. If we follow the steps in a flowchart it will lead us to the
solution of a particular problem.
This shows where the
OVAL algorithm starts and stops
Parallelogram This represents INPUT of
data or OUTPUT of
information.
Flowchart Symbols
Rectangle This symbol represents processing.
That is, calculations or assignments.
This represents a decision. That is, a
Diamond
choice between one process and
another.
Arrow This symbolizes a flow line. It
connects the different symbols and
shows the direction of the
algorithm.
Flowchart Symbols
•Preparation symbol, which is represented by a
hexagon. These are used to show operations which
have no effect other
•A small circle symbolizes a connector which is used
to join two arrows and is usually seen when a
decision is to be made
Flowchart
START
Enter two numbers
num1, num2
Sum num1 + num2
Product num1 * num2
Sum, Product
STOP
Class Activity
• Write a pseudocode algorithm that accepts
the length and width of a rectangle. Calculate
and output the area and perimeter.
• Draw the corresponding flowchart.