You are on page 1of 11

Flowchart is a diagrammatic representation of sequence of logical steps of a

program. Flowcharts use simple geometric shapes to depict processes and


arrows to show relationships and process/data flow.

Use of a flowchart

Following are the uses of a flowchart:


 It is a pictorial representation of an algorithm that increases the
readability of the program.
 Complex programs can be drawn in a simple way using a flowchart.
 It helps team members get an insight into the process and use this
knowledge to collect data, detect problems, develop software, etc.
 A flowchart is a basic step for designing a new process or add extra
features.
 Communication with other people becomes easy by drawing
flowcharts and sharing them.

When to use flowchart

Flowcharts are mainly used in the below scenarios:


 It is most importantly used when the programmers make projects.
As a flowchart is a basic step to make the design of projects
pictorially, it is preferred by many.
 When the flowcharts of a process are drawn, the programmer
understands the non-useful parts of the process. So flowcharts are
used to separate useful logic from the unwanted parts.
 Since the rules and procedure of drawing a flowchart are universal,
flowchart serves as a communication channel to the people who are
working on the same project for better understanding.
 Optimizing a process becomes easier with flowcharts. The
efficiency of code is improved with the flowchart drawing.

Types of Flowcharts

Three types of flowcharts are listed below:


1. Process flowchart: This type of flowchart shows all the activities
that are involved in making a product. It basically provides a
pathway to analyze the product to be built. A process flowchart is
most commonly used in process engineering to illustrate the relation
between the major as well as minor components present in the
product. It is used in business product modeling to help understand
employees about the project requirements and gain some insight
about the project.
2. Data flowchart: As the name suggests, the data flowchart is used
to analyze the data, specifically it helps in analyzing the structural
details related to the project. Using this flowchart, one can easily
understand the data inflow and outflow from the system. It is most
commonly used to manage data or to analyze information to and fro
from the system.
3. Business Process Modeling Diagram: Using this flowchart or
diagram, one can analytically represent the business process and
help simplify the concepts needed to understand business activities
and the flow of information. This flowchart illustrates the business
process and models graphically which paves a way for process
improvement.

Flowchart Symbols
Here is a chart for some of the common symbols used in drawing flowcharts.

Symbol Symbol Name Purpose

Used at the beginning and end of the algorithm to


Start/Stop
show start and end of the program.

Indicates processes like mathematical operations.


Process

Input/ Output Used for denoting program inputs and outputs.


Stands for decision statements in a program,
where answer is usually Yes or No.
Decision

Shows relationships between different shapes.


Arrow

Connects two or more parts of a flowchart, which


On-page Connector are on the same page.

Connects two parts of a flowchart which are


Off-page Connector spread over different pages.

Guidelines for Developing Flowcharts


These are some points to keep in mind while developing a flowchart −
 Flowchart can have only one start and one stop symbol
 On-page connectors are referenced using numbers
 Off-page connectors are referenced using alphabets
 General flow of processes is top to bottom or left to right
 Arrows should not cross each other

Advantages of Flowchart

 It is the most efficient way of communicating the logic of system.


 It act like a guide for blueprint during program designed.
 It also helps in debugging process.
 Using flowchart we can easily analyze the programs.
 flowcharts are good for documentation.

Disadvantages of Flowchart
 Flowcharts are difficult to draw for large and complex programs.
 It does not contain the proper amount of details.
 Flowcharts are very difficult to reproduce.
 Flowcharts are very difficult to modify.
Algorithm
Algorithm is a step – by – step procedure which is helpful in solving a
problem. If, it is written in English like sentences then, it is called as
‘PSEUDO CODE’.

Properties of an Algorithm
An algorithm must possess the following five properties −

 Input
 Output
 Finiteness
 Definiteness
 Effectiveness

Example
Algorithm for finding the average of three numbers is as follows −

 Start
 Read 3 numbers a,b,c
 Compute sum = a+b+c
 Compute average = sum/3
 Print average value
 Stop

Qualities of a Good Algorithm


 Input and output should be defined precisely.

 Each step in the algorithm should be clear and unambiguous.

 Algorithms should be most effective among many different ways to


solve a problem.
 An algorithm shouldn't include computer code. Instead, the algorithm
should be written in such a way that it can be used in different
programming languages.

 Algorithm 1: Add two numbers entered by the user


 Step 1:
Start
 Step 2:
Declare variables num1, num2 and sum.
 Step 3:
Read values num1 and num2.
 Step 4:
Add num1 and num2 and assign the result to sum.
 sum←num1+num2
 Step 5: Display sum
 Step 6: Stop

Algorithm 2: Find the largest number among three


numbers

Step 1: Start

Step 2: Declare variables a,b and c.

Step 3: Read variables a,b and c.

Step 4: If a > b

If a > c

Display a is the largest number.

Else

Display c is the largest number.

Else

If b > c
Display b is the largest number.

Else

Display c is the greatest number.

Step 5: Stop

Algorithm 4: Find the factorial of a number

Step 1: Start

Step 2: Declare variables n, factorial and i.

Step 3: Initialize variables

factorial ← 1

i ← 1

Step 4: Read value of n

Step 5: Repeat the steps until i = n

5.1: factorial ← factorial*i

5.2: i ← i+1

Step 6: Display factorial

Step 7: Stop
What is While Loop?
A While loop is the most straightforward looping structure. It is an
entry-controlled loop. In a while loop, a condition is evaluated before
processing a body of the loop. If a condition is true, then and only then
the body of a loop is executed.

After the body of a loop is executed, the control again goes back to
the beginning, and the condition is checked. If it is true, the same
process is executed until the condition becomes false. Once the
condition becomes false, the control goes out of the loop.

In a while loop, if the condition is not true, then the body of a loop will
not be executed, not even once.

Syntax of While loop in C


Here is a syntax of While loop in C programming:
while (condition) {
statements;
}

Program to print table for the given number using


while loop in C
#include<stdio.h>
int main(){
int i=1,number=0,b=9;
printf("Enter a number: ");
scanf("%d",&number);
while(i<=10){
printf("%d \n",(number*i));
i++;
}
return 0;
}
Output
Enter a number: 50
50
100
150
200
250
300
350
400
450
500
do-while loop in C
The do while loop is a post tested loop. Using the do-while loop, we can
repeat the execution of several parts of the statements. The do-while loop is
mainly used in the case where we need to execute the loop at least once. The
do-while loop is mostly used in menu-driven programs where the termination
condition depends upon the end user.

The syntax of the do-while loop is given below:


do{
//code to be executed
}while(condition);

Program to print table for the given number using do while loop
#include<stdio.h>
int main(){
int i=1,number=0;
printf("Enter a number: ");
scanf("%d",&number);
do{
printf("%d \n",(number*i));
i++;
}while(i<=10);
return 0;
}
Output
Enter a number: 5
5
10
15
20
25
30
35
40
45
50
Differences between while and do-while loop in C
While Do While
It checks the condition first and This loop will execute the
then executes statement(s) statement(s) at least once, then the
condition is checked.
While loop allows initialization of Do while loop allows initialization of
counter variables before starting counter variables before and after
the body of a loop. starting the body of a loop.
It is an entry controlled loop. It is an exit controlled loop.
We do not need to add a We need to add a semicolon at the
semicolon at the end of a while end of the while condition.
condition.
In case of a single statement, we Brackets are always needed.
do need to add brackets.
In this loop, the condition is The loop condition is specified after
mentioned at the starting of the the block is executed.
loop.
Statement(s) can be executed Statement is executed at least once.
zero times if the condition is false.
Syntax: Syntax:
while (condition) { do{
Statements; // loop body Statements; //loop body
} } while (condition);

You might also like