Algorithms and Flowcharts
Algorithms and Flowcharts
• The algorithm and flowchart are two types of tools to explain the
process of a program.
• Algorithms and flowcharts are two different tools that are helpful for
creating new programs, especially in computer programming.
• An algorithm is a step-by-step analysis of the process, while a
flowchart explains the steps of a program in a graphical way.
Definition of Algorithm
• Writing a logical step-by-step method to solve the problem is called
the algorithm.
• In other words, an algorithm is a procedure for solving problems. In
order to solve a mathematical or computer problem, this is the first
step in the process.
• An algorithm includes calculations, reasoning, and data processing.
• Algorithms can be presented by natural languages, pseudocode, and
flowcharts, etc.
• 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 in order to get the expected results.
• An algorithm is a step-by-step description of how to solve any given
problem.
• Alternately, one could say that the algorithm of every given program
is a step-by-step solution description of the problem or program that
has been presented.
• In order to be considered an algorithm, a sequence of instructions
must have the following characteristics:
Each and every one of the written instructions ought to be clear and
unmistakable.
Each instruction should be carried out at a predetermined interval.
There should not be an unlimited amount of instructions that are repeated.
The intended end result must be achieved after carrying out all of the steps
outlined in the instructions.
Example of an Algorithm
• Create an algorithm for calculating the sum of the first N numbers
// C program to illustrate
// semantic error
void main()
{
int a, b, c;
a + b = c; //semantic error
}
#include<stdio.h>
void main()
{
int n = 9, div = 0;
// wrong logic
// number is divided by 0,
// so this program abnormally terminates
div = n/0;