Algorithm and Flowchart with Examples

We will study about algorithms and flowcharts with examples in this post or lesson. Let us begin with the algorithm.


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:

Example of an Algorithm

Let's look at an algorithm example and see how we can write an algorithm for a given problem.

Create an algorithm for calculating the sum of the first N numbers

In this case, we must develop an algorithm or a step-by-step solution description for calculating the sum of the first N numbers. So, what are we still waiting for? Let us now create an algorithm to address this problem.

1. Read the value of n
2. Put i=1, sum=0
3. if(i>n), go to step 7
4. Update s = s + i
5. Update i = i+1
6. go to step 3
7. Print the value of s
8. Stop

As you can see from the preceding algorithm, which is presented in eight steps, it assists you in creating a program to find the sum of the first N numbers.

Create an algorithm to determine the least and biggest number from a given set of numbers

In this case, we must create an algorithm that will assist us in determining the smallest and largest number from a given list of integers.

1. Read the entire list of numbers
2. Assign the first number as the largest number
3. Assign the first number as the smallest number
4. Repeat steps 5 through 7 as long as the largest and smallest numbers are there
5. Read the number and compare the largest and smallest values
6. If the number is greater than the largest, then the current number is the largest.
7. If the number is less than the smallest, then the current number is the smallest.
8. Print the largest number
9. Print the smallest number
10. Stop

You can now easily apply all of the above stages to create a program that finds the largest and smallest number from a given list of integers.

Flow Chart

A flow chart is the pictorial representation of any given task, problem, or program.

Types of Flow Chart

There are two types of flow charts, given here with their short descriptions:

Advantages of Flow Charts

Here are a few of the most important reasons why you should use flow charts before applying any solution to a program:

Disadvantages of Flow Charts

Here is a list of some primary or main disadvantages of using flowcharts for any given problem:

Basic Symbols used in Flow Chart

Standardization of these fundamental flow chart symbols has been completed by the American National Standard Institute (ANSI).


In order to denote the beginning and the conclusion of the program, the terminal symbol is utilized. The following is the sign for the terminal:

flowchart algorithm terminal


The input and output of an operation are typically represented as two sides of a parallelogram. The following is a demonstration of an input/output symbol that may be used in a flowchart:

flowchart input output

Processing Symbol

The rectangle symbol is required to be used whenever there is a need to denote a processing operation in a flowchart. The following is a demonstration of the symbol for the rectangle that is used in creating flowcharts to represent activities involving storage or arithmetic:

flowchart processing symbol

Decision Symbol

It is necessary to make use of a box in the shape of a diamond in order to denote the stage of the decision-making process. This is the demonstration symbol for a box in the shape of a diamond:

flowchart decision symbol

Flow of Lines

A program's logic flow can be analyzed by tracing the path taken by the lines of code. It is necessary to draw lines in the spaces between each box on the flowchart to show the direction in which the program will proceed. The example of the line flow symbol is as follows:

flowchart flow of lines

Connector Symbol

When connecting the various components of a flowchart, we need to draw a circle. The demo symbol for a circle that is used in a flowchart looks like this:

flowchart connector symbol

Example of a Flowchart

Let's look at a flowchart example to understand how to use all of the symbols described above to build a visual representation that describes the solution to any program or problem.

Create a flowchart to determine the greatest of three numbers

The flowchart shown in the figure below assists in determining the greatest of the three numbers:

flowchart largest of three number

Make a flowchart that computes the sum of the first N numbers

Another flowchart for calculating the sum of the first N natural numbers is shown below:

flowchart sum n numbers

Computer Fundamentals Quiz

« Previous Tutorial Next Tutorial »

Liked this post? Share it!