Flowcharts With Examples in Programming

By | April 4, 2020

Topic: Flowcharts With Examples and Explanation of Symbols

Task: Today we will discuss the Role of Flowcharts in Computer Programming – Tutorial for Beginners. This is a basic tutorial on how to draw some basic flow charts to be used in computer program planning process.

There will be an introduction to basic symbols needed to draw a program flow chart. We will present live flowchart examples for some programs.

Flowcharts with examples and symbols

Flowcharts with examples and symbols

Flowcharts With Examples and Explanation of Symbols

What Do You Mean by a Flow Chart?

A flowchart is a graphical representation of an algorithm. An algorithm is a step by step procedure to solve a problem. We will explain the concept with an example of an algorithm to find the sum of two numbers. We will draw an example flowchart for the above mentioned SUM algorithm to add two numbers.

Algorithm SUM

  1. Start
  2. Input two numbers X,Y
  3. Add X,Y and store sum in to SUM
  4. Print SUM
  5. Stop

How To Draw A Program Flowchart?

To draw a program flow chart we need a set of basic symbols. These symbols will represent different actions like, start, stop, input, output and process or calculation. Some other symbols are for showing direction of control flow, decision making and looping.

Symbols Used in Flowcharts

Flowcharts use different basic symbols to represent program statements.

Basic Program Flowchart Symbols

Basic Program Flowchart Symbols

1. Start / End

The An oval like symbol is used to represent start and end of a flowchart.

2. Flow Lines / Arrow

Arrow lines are used to show the direction of flow in the flowchart.

3. Input / Output

Parallelogram symbols are used to show input and output.

4. Process

A rectangle symbol is used to show a process in a flowchart. A process may be a simple assignment statement like A=10 or a calculation like SUM= A + B etc.

5. Selection

A diamond symbol is used to show a selection step in a flowchart. A diamond shows a decision making statement like if-else sttement in a program. A condition like Num1 > Num2 is placed in the diamond symbol. We will use arrow lines to show the possible direction of control flow from the diamond symbol. For example, if we are checking that if the given two numbers are equal then show “Numbers are Equal” otherwise show the message “Numbers are different.

Program flow chart example with decision making symbol

Program flow chart example with decision making symbol

Excercise 1 : Q: Develop a flow chart for a C++ Program to input three sides A, B, C of a triangle and calculate / display the are of triangle using the formula:

Flowcharts With Examples and Explanation of Symbols

Creating a Program Flow chart example

First of all, we design an algorithm for calculating area of triangle:

Algorithm: Area of  Triangle

//This algorithms takes the values of three sides of a triangle

//and calculaes its area

1. Start
2. Input the values for three sides a,b,c
3. Calculate s = (a + b + c ) / 2
4. Calculate area = sqrt( s*(s-a)*(s-b)*(s-c))
5. print “Area of Triangle=”, area
6. End

How To Convert An Algorithm to a Flowchart

Normally there is a one step to one symbol correspondence in conversion of an algorithm to the program flowchart. All symbols are connected with the help of  directed flow lines / arrows. These flow lines show the direction of flow in a flowchart.

For example, for the above algorithm we use one symbol in flow chart for each algorithmic step:

  1. Start symbol
  2. Parallelogram / input symbol (I/o symbol)
  3. Process / calculation symbol
  4. Process or calculate symbol
  5. Parallelogram –  output symbol (I/O symbol)
  6. End or stop symbol

 

Flow chart Area of Triangle

Flowcharts With Examples and Explanation of Symbols

how to design flowchart for Area of Triangle

How to implement a Loop in a Program Flowchart

We can implement a looping statement in a flowchart using the decision symbol that is the diamond symbol.

For example, an example of a flowchart to display 1 to 10 numbers is as follows:

Using loop in a flowchart

Using loop in a flowchart

Here we use decision symbol and  process symbol to show a loop in the program.

  1. First of all we initialize C=1 in a process symbol before start of the loop.
  2. Next we use a decision symbol to check the loop condition C<=10.
  3. If condition is false, the loop will be terminated
  4. If the condition is true, the loop body consisting of two symbols, to print C and Increment c loop counter variable will be executed.

Flowcharts With Examples and Explanation of Symbols

So, we study today about the importance of flowcharts in Computer programming. We also discussed the different symbols used in flow charting in program planning / program design technique.

We discussed the different example flow charts  here.

Flowcharts in Computer Programming

Some File Programs in C++:

Loading

Leave a Reply

Your email address will not be published. Required fields are marked *