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 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
- Start
- Input two numbers X,Y
- Add X,Y and store sum in to SUM
- Print SUM
- 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.
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.
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:
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
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:
- Start symbol
- Parallelogram / input symbol (I/o symbol)
- Process / calculation symbol
- Process or calculate symbol
- Parallelogram – output symbol (I/O symbol)
- End or stop symbol
Flow chart 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:
Here we use decision symbol and process symbol to show a loop in the program.
- First of all we initialize C=1 in a process symbol before start of the loop.
- Next we use a decision symbol to check the loop condition C<=10.
- If condition is false, the loop will be terminated
- 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++:
- CPP Program to write / add records in Binary File
- C ++ Program To Display All File Records
- Menu Driven C++ Program To Read and Write in Binary File
- Copy All Records to Another File Program in C Plus Plus