Algorithm and Flowcharts
Algorithm and Flowcharts
The software developer makes use of tools like algorithms and flowcharts to
develop the design of the program.
Algorithm
An algorithm represents the logic of the processing to be performed. It is a
sequence of instructions which are designed in such a way that if they are
executed in the specified sequence, the desired goal is achieved. It is imperative
that the result be obtained after execution of a finite number of steps.
In an algorithm,
- Each and every instruction has to be precise and clear.
- The instruction has to be executed in a finite time.
- When the algorithm terminates the desired result should be achieved.
Advantages of Algorithms
• It is a step-wise representation of a solution to a given problem, which
makes it easy to understand.
• An algorithm uses a definite procedure.
• It is not dependent on any programming language, so it is easy to
understand for anyone even without programming knowledge.
• Every step in an algorithm has its own logical sequence so it is easy to
debug.
Flowchart
A flowchart is a pictorial representation of the algorithm. It represents the steps
involved in the procedure and shows the logical sequence of processing using
boxes of different shapes. The instruction to be executed is mentioned in the
boxes.
These boxes are connected together by solid lines with arrows, which indicate
the flow of operation. The first step in the design of a program is the algorithm.
The algorithm is then represented in the form of a flowchart and the flowchart is
then expressed in the computer language to actually prepare the computer
program.
The first design of flowchart goes back to 1945 which was designed by John
Von Neumann. Unlike an algorithm, Flowchart uses different symbols to design
a solution to a problem. It is another commonly used programming tool. By
looking at a Flowchart, one can understand the operations and sequence of
operations performed in a system. Flowchart is often considered as a blueprint
of a design used for solving a specific problem.
Advantages of flowchart:
• Flowchart is an excellent way of communicating the logic of a program.
• Easy and efficient to analyse problem using flowchart.
• During program development cycle, the flowchart plays the role of a
blueprint, which makes program development process easier.
• After successful development of a program, it needs continuous timely
maintenance during the course of its operation. The flowchart makes
program or system maintenance easier.
• It is easy to convert the flowchart into any programming language code.
Next on the basis of this step wise algorithm develop the flowchart using the
appropriate flowchart symbols as follows:
Flowchart:
Start
Input Temp. in C
Calculate F
F= 9/5 C + 32
Print Temp. in F
Stop
Algorithm :
Step 1: Start.
Step 2: Input values of A and B.
Step 3: Compare values of A and B (Is A >B?).
Step 4: If yes then print “A is greater than B”.
Step 5: If no, the print “B is greater than A”.
Now draw the flowchart for the above.
3. Algorithm & Flowchart to find the sum of two numbers
Algorithm
Step-1 Start
Step-2 Input first numbers say A
Step-3 Input second number say B
Step-4 SUM = A + B
Step-5 Display SUM
Step-6 Stop
Flowchart:
4. Algorithm & Flowchart to find Area and Perimeter of Rectangle
L : Length of Rectangle
B : Breadth of Rectangle
AREA : Area of Rectangle
PERIMETER : Perimeter of Rectangle
Algorithm
Step-1 Start
Step-2 Input Side Length & Breadth say L, B
Step-3 Area = L x B
Step-4 PERIMETER = 2 x ( L + B)
Step-5 Display AREA, PERIMETER
Step-6 Stop