What is Algorithm?
The word “algorithm” relates to the name of the mathematician Al-khowarizmi, which means a procedure or a technique.
The word Algorithm
means “a process or set of rules to be followed in calculations or
other problem-solving operations”. Therefore Algorithm refers to a set
of rules/instructions that step-by-step define how a work is to be
executed upon in order to get the expected results.
It can be understood by taking an example of cooking a new recipe. To
cook a new recipe, one reads the instructions and steps and execute them
one by one, in the given sequence. The result thus obtained is the new
dish cooked perfectly. Similarly, algorithms help to do a task in
programming to get the expected output.
"a logical step-by-step method to solve the problem is called algorithm"
What is Flowchart?
A flowchart is a blueprint that pictorially represents the algorithm and
its steps. Flowchart is diagrammatic /Graphical representation of sequence of steps to solve a problem.
A flowchart
is a graphical representation of an algorithm. Programmers often use it
as a program-planning tool to solve a problem. It makes use of symbols
which are connected among them to indicate the flow of information and
processing.
The process of drawing a flowchart for an algorithm is known as “flowcharting”.
To draw a flowchart following standard symbols are use
Difference between Algorithm and Flowchart
Algorithm
|
Flowchart
|
It is a procedure for solving problems.
|
It is a graphic representation of a process.
|
The process is shown in step-by-step instruction.
|
The process is shown in block-by-block information diagram.
|
It is complex and difficult to understand.
|
It is intuitive and easy to understand.
|
It is convenient to debug errors.
|
It is hard to debug errors.
|
The solution is showcased in natural language.
|
The solution is showcased in pictorial format.
|
It is somewhat easier to solve complex problem.
|
It is hard to solve complex problem.
|
It costs more time to create an algorithm.
|
It costs less time to create a flowchart.
|
-----------------------------------------------------------------------------------------------------------------
1) Algorithm & Flowchart to find the sum of two numbers
Algorithm:
Step-1 Start
Step-2 Input first numbers say A
Step-3 Input second number say B
Step-4 SUM = A + B
Step-5 Display SUM
Step-6 Stop
Flowchart:
-----------------------------------------------------------------------------------------------------------------
2)Algorithm & Flowchart to Print 1 to 20.
Algorithm:
Step 1: Initialize X as 0,
Step 2: Increment X by 1,
Step 3: Print X,
Step 4: If X is less than 20 then go back to step 2.
Flowchart:
---------------------------------------------------------------------------------------------------------------------------
3) Algorithm & Flowchart to Determine and Output Whether Number N is Even or Odd
Algorithm:
-
Step 1: Read number N,
-
Step 2: Set remainder as N modulo 2,
-
Step 3: If remainder is equal to 0 then number N is even, else number N is odd,
-
Step 4: Print output.
Flowchart:
--------------------------------------------------------------------------------------------------------------------------
4) Algorithm & Flowchart to find Area and Perimeter of Rectangle
L : Length of Rectangle
B : Breadth of Rectangle
AREA : Area of Rectangle
PERIMETER : Perimeter of Rectangle
Algorithm:
Step-1 Start
Step-2 Input Side Length & Breadth say L, B
Step-3 Area = L x B
Step-4 PERIMETER = 2 x ( L + B)
Step-5 Display AREA, PERIMETER
Step-6 Stop