Flowcharts
Flowcharts
Input/Output: A parallelogram denotes any function of input/output type. Program instructions that take
input from input devices and display output on output devices are indicated with parallelogram in a
flowchart.
Processing: A box represents arithmetic instructions. All arithmetic processes such as adding,
subtracting, multiplication and division are indicated by action or process symbol.
Decision Diamond symbol represents a decision point. Decision based operations such as yes/no question
or true/false are indicated by diamond in flowchart.
Connectors: Whenever flowchart becomes complex or it spreads over more than one page, it is useful to
use connectors to avoid any confusions. It is represented by a circle.
Flow lines: Flow lines indicate the exact sequence in which instructions are executed. Arrows represent
the direction of flow of control and relationship among different symbols of flowchart.
Rules For Creating Flowchart :
A flowchart is a graphical representation of an algorithm.it should follow some rules while creating a
flowchart
Rule 1: Flowchart opening statement must be ‘start’ keyword.
Rule 2: Flowchart ending statement must be ‘end’ keyword.
Rule 3: All symbols in the flowchart must be connected with an arrow line.
Rule 4: The decision symbol in the flowchart cannot be associated with the arrow line.
Advantages of Flowchart:
Flowcharts are a better way of communicating the logic of the system.
Flowcharts act as a guide for blueprint during program designed.
Flowcharts help in debugging process.
With the help of flowcharts programs can be easily analyzed.
It provides better documentation.
Flowcharts serve as a good proper documentation.
Easy to trace errors in the software.
Easy to understand.
The flowchart can be reused for inconvenience in the future.
It helps to provide correct logic.
Disadvantages of Flowchart:
It is difficult to draw flowcharts for large and complex programs.
There is no standard to determine the amount of detail.
Difficult to reproduce the flowcharts.
It is very difficult to modify the Flowchart.
Making a flowchart is costly.
Some developer thinks that it is waste of time.
It makes software processes low.
If changes are done in software, then the flowchart must be redrawn
Example : Draw a flowchart to input two numbers from the user and display the largest of two
numbers
Programming Techniques
Every programmer follows a different programming technique. One choses a technique according to his comfort level.
Subsequently there are four different programming techniques. A programmer learns all four of them during his tenure.
Unstructured Programming
Procedural Programming
Modular Programming
Unstructured programming technique is for beginners. Programmers begin programming by making simple programs
which consists of only the main method. All the statements required for the code are written in the main method. It uses
and modifies the data global to the program.
For example:
Consider a simple program of addition of two numbers in C++.
#include
#include
void main()
{
int a,b,c;
clrscr();
cout << "Enter the first number";
cin >> a;
cout << "Enter the second number";
cin >> b;
c=a+b;
cout << "The sum is:" << c;
getch();
}
Here all the coding is done in the main program. No other method is created. This is unstructured programming and
usually beginners follow this technique.
Drawbacks:
When the program size increases, it becomes difficult to maintain.
Here for each task, a new procedure is created. This procedure is called in the main program. Thus if the same code is
required elsewhere, it is not rewritten, only the function need to be called. Thus code remains small.
For example:
The same program above is developed using a function add.
#include
#include
void main()
{
int add(int,int);
int a,b,c;
clrscr();
cout << "Enter the first number";
cin >> a;
cout << "Enter the second number";
cin >> b;
c=add(a,b);
cout<<"The sum is:" << c;
getch();
}
int add(int x,int y)
{
int z=x+y;
return z;
}
Here if addition is required elsewhere, only the function need to be called, whole code need not be written.
Modular Programming:
In modular programming procedures with some common functionality are grouped together into separate modules. Thus a
program now is not a single entity. It is categorized into several smaller modules. To enable usage of general procedures
or groups of procedures also in other programs, they must be separately available. For that reason, modular programming
allows grouping of procedures into modules.
Object oriented programming technique works on objects which is considered smallest unit of the object oriented
languages. Problem is scattered around in the objects and the main method only collects these objects. Here data is
given importance rather than procedures, thus maintaining data security.
Also it follows bottom-up approach.
For example:
#include
#include
class Addition
{
int a,b,c;
public:
void read()
{
cin >> a;
cin >> b;
}
void add()
{
c=a+b;
}
void display()
{
cout << "The sum is:" << c;
}
};
void main()
{
Addition obj; //object creation
cout << "Enter the numbers";
obj.read();
obj.add();
obj.display();
getch();
}
This technique has become most famous as it correlates with the real world.