1.-Algorithm
1.-Algorithm
solve a problem or to perform a task. One of the most obvious examples of an algorithm is a
recipe.
• Flowchart
• Pseudocode
• Divide and Conquer
• Input Process Output (IPO)
Input-Process-Output (IPO) model is a widely used approach in systems analysis and software
engineering for describing the structure of an information processing program or other process.
A computer program or any other sort of process using the input-process-output model
receives inputs from a user or other source, does some computations on the inputs, and returns
the results of the computations. The system divides the work into three categories:
EXAMPLE 1
Compute the sum of three numbers, the program must:
Conquer - Solve the smaller sub-problems. If the sub-problem is small enough, then solve it
directly.
Combine - Merge the solutions of the sub-problems to get the solution to the actual or
original problem.
Pseudocode is an outline of a program, written in a form that can easily be converted into real
programming statements. It resembles the actual program that will be implemented later.
However, it cannot be compiled nor executed.
Initialization of variables
Arithmetic operations
Relational operations
For example, a program might be written to compute the price of apples if the quantity in kg
and price per kg are given. The program must:
Ask the user for the weight (quantity in kg) of apple and price per kilogram (input)
a. Start
b. Read Quantity
c. Read PricePerKg
e. Print Price
f. End
a. Start
b. Read Length
c. Read Width
e. Print Area
f. End
Flowchart - A flowchart is a diagram representing the logical sequence in which a combination of
steps or operations is to be performed. It consists of labeled geometrical symbols that are
interconnected. It is also a visual representation of an algorithm. It is intended for communication
and documentation.
Terminal Symbol (oval) – use to designate the beginning and the end of the program.
Input/output Symbol (parallelogram) – represents an instruction to an input or an output device.
Decision Symbol (diamond) – denotes a point in the program where more than one path can be
taken.
Preparation Symbol (hexagon) – represent an instruction or group of instructions that will alter
or modify a program’s course of execution. It is commonly used to specify operations such as
control, index register, initialization, switch setting, and in indicating loops.
On-page Connector (small circle) – a none processing symbol use to connect one part of a
flowchart to another without drawing flow lines.
Off-page Connector (small pentagon) – to designate entry to or exit from a page when a flowchart
requires more than one page.
Flow Direction Indicators (arrowheads) – use to show the direction of processing or data flow.
These are added to flow lines if a flowchart appears confusing is its layout. Arrowheads are not
required when the logic flow is from top to bottom or from left to right.
Flow lines (horizontal/vertical lines) – use to show reading order or sequence in which flowchart
symbols are to be read. Flow lines are sometimes drawn with arrowheads. The commonly
accepted practice is to indicate an arrowhead if the logic flow is from right to left or from bottom
to top.
OPERATORS
EXAMPLE NO 1 – Make a flowchart that asks the weight of apple (kg) and its price per kilogram
and display the total.
EXAMPLE NO 2 – Make a flowchart that checks if a grade is passed or failed.
EXAMPLE WITH LOOP