ALGORITHMS AND FLOWCHARTS
Class 4th
Introduction
In your daily life, you carry out
certain steps in a sequential order to
perform a task and get the desired
result.
Similarly, to solve any problem on a
computer, you analyse and
understand the nature of the problem
first. You plan the input and apply
appropriate methods, step-by-step,
to get the desired result.
ALGORITHM
• An algorithm is a set of sequential steps to
solve any logical or mathematical problem.
• It is always written in simple language.
INPUT
An algorithm can
take input in zeros or INDEPENDENT
greater quantities. It An algorithm should have Characteristics
should have a well- of an Algorithm
defined input. step-by-step instructions,
which should be free from
OUTPUT any programming code.
An algorithm should
have at least one
well-defined output
that should match
the desired result UNAMBIGUOUS
An algorithm should be clear
FINITENESS and explicit. Each of its steps
An algorithm must should be clear and must
terminate after a
finite number of
lead to only one meaning
steps.
An Algorithm to set your school bag:
Step 1: Start
Step 2: See the timetable.
Step 3: Go to your bookshelf.
Step 4: Take out the books and notebooks according to the next day’s schedule.
Step 5: Put them in the bag.
Step 6: Close the bag.
Step 7: Stop
Algorithm to calculate the sum and average of
three numbers:
Step 1: Start
Step 2: Input the first number(A).
Step 3: Input the second number(B).
Step 4: Input the third number(C).
Step 5: Find the Sum of three numbers (A+B+C).
Step 6: Find the Average (A+B+C)/3.
Step 7: Print Sum and Average.
Step 8: Stop
Algorithm to compare two numbers and find the
greater one:
Step 1: Start
Step 2: Input two numbers and store them in A and B.
Step 3: Check whether A=B or not. If true, then go to step 4,
else go to step 5.
Step 4: Print “Both numbers are equal”, and go to step 8.
Step 5: Compare A and B. If A is greater than B, go to step 6,
else go to step 7.
Step 6: Print “A is greater than B” and go to step 8.
Step 7: Print “B is greater than A” and go to step 8.
Step 8: Stop
FLOWCHART
• A flowchart is the graphical
representation of an algorithm.
• It is a step-by-step process of
representing the solution of a particular
problem in a graphical or pictorial form.
• In other words, it is a systematic
pictorial representation of an algorithm.
• It is very easy to draw and understand.
Flowchart Symbols and their functions
Start / Stop box:
It is used at the beginning and end of the flowchart.
Input / Output box:
It is used for accepting input or giving output of the
program.
Flowchart Symbols and their functions
Processing box:
It is used for writing the processing instructions and
doing calculations.
Decision / Condition box:
It is used for checking or applying any condition in
the program.
Flowchart Symbols and their functions
Flow lines:
These arrows are used to connect the various
geometrical symbols in a flowchart.
Flow lines show the direction in which the program is
moving.
Connectors:
These are used to connect one part of the flowchart
to another.
Example1: Write down the process of making tea.
Example2: Calculate the sum, difference, and product of
two numbers.