Chapter One
Introduction to Algorithms and Flowcharts
OBJECTIVES LEARNING OUTCOMES (LO)
1. Explain introductory concepts 14. Identify and
and principles used in comprehend technical
programming. documentation..
2. Explain the general
15. Prepare simple
environment and steps in
readable user
programming using Algorithm,
documentation.
Flowchart,
(Input/Process/Output/). 1
•A computer is an electronic machine which
performs computational and logical
procedures as per requirements of a user.
• Requirements of a user are
communicated to computer by the help of
programs/software.
•Writing programs and software is a pure
engineering activity and all engineering
products need a design to be prepared
before going for actual implementation. 2
•For every program/software we always need
to prepare a design, which is called algorithm.
1.1 The Algorithm:
•It is the logical steps used to process the
input data in order to produce the
required information and results.
• It is the step by step procedure to solve
a problem.
3
The design of an algorithm to solve a
specific problem needs:
- high knowledge and big practical
experience.
- and good background about the
details of the problem to be solved.
For one problem as there can be multiple
solutions, so there can be multiple
algorithms for a problem.
4
1.2 Flowcharts:
•A flowchart is a graphical representation
of an algorithm.
•It is very helpful in understanding the
algorithm.
•After designing the flowchart, it is easy
to write the program in any high level
language.
5
Flowchart Symbols
6
Flowchart Symbols
7
Basic Guidelines for drawing Flowcharts:
A. Before drawing flowchart:
1. Identify inputs and outputs.
2. Identify the steps of processing.
3. Draw the flowcharts.
B. Generally, the direction of flow is from
top to bottom (can be from left to right).
8
C. Only one flow line should Enter/Exit
from a process or Input / Output.
9
D. One flow line should Enter a decision
symbol, but two flow lines, (Yes and NO),
should Exit it.
E. Only one flow line will exit from Start
and one will enter in End.
10
F. Multiple flows can be joined to one flow
using Connector symbol.
G. Test the validity of the flowchart by
passing through it with a simple test data.
1.3 Examples of Algorithms & Flowcharts:
Problem 1: Write an algorithm and draw
the flowchart for finding the average of
two numbers.
11
12
Problem 2: Write an algorithm and draw
the flowchart to compute the maximum of
two numbers.
13
14
15
Exercise Problems Page 9: Solve all.
16