2. The Teacher
Algorithm and Flowchart
Algorithm :
• Before solving a problem, one should know what to do, how to do it, and what types of steps
should be taken. So, an algorithm is a step-by-step method for solving a problem.
• An algorithm refers to a set of instructions that define the execution of work to get the
expected results.
• To make the program work properly, we must have to properly design the algorithm.
• Designing the algorithm helps to utilize the computing resources effectively.
• Generally, the algorithms are written in natural language or in plain English language.
• We can represent algorithms via flowcharts, pseudo code, and others.
Algorithm and Flowchart
3. The Teacher
Algorithm and Flowchart
Advantages of algorithm
• Algorithms are easy to write.
• There is a use of human-readable techniques to understand logic.
• For big problems, algorithms can be written with moderate steps.
Disadvantages of algorithm
• Algorithms are difficult to debug.
• It is hard to show branches and loops using an algorithm.
• Jumping (or goto statements) makes the algorithm hard to trace the problems.
Algorithm and Flowchart
4. The Teacher
Algorithm and Flowchart
• Now, let's see an example of an algorithm.
• Example: Write an algorithm to print the numbers from 1 to 20.
Algorithm:
Step 1: Initialize a variable 'x' as 0,
Step 2: Increment the variable 'x' by 1,
Step 3: Print the variable 'x'
Step 4: If 'x' is less than 20, then go back to step 2. Otherwise, go to the next step.
Step 5: Exit.
Algorithm and Flowchart
5. The Teacher
Algorithm and Flowchart
Flow Chart
• Flow chart is the pictorial representation of any given task or problem or program.
Or
• The Flowchart is the most widely used graphical representation of an algorithm
Advantages of Flow Charts
Here are some of the main and primary advantages of using the flow charts are:
1. Effective Analysis - Using flow chart, any problem can be analyzed in more effective way
2. Communication - Flowcharts are much better way of communicating any logic of a system
to all concerned.
3. Efficient Coding - Every flowcharts acts as a guide or blueprint during the systems analysis
and program development phase
Algorithm and Flowchart
6. The Teacher
Algorithm and Flowchart
4. Proper Debugging - The flowcharts helps in debugging process
5. Efficient Program Maintenance - The maintenance of operating program becomes very
easy using flowcharts.
6. Proper Documentation - Program flowcharts serve as a good program
documentation, which is needed for various purposes
Disadvantages of Flow Charts
Here are the list of some primary or main disadvantages of flowcharts for any given problem:
1. Complex Logic - Sometime, the given program logic is quit complicated. In that case, it
becomes very difficult task to design or draw a flowchart for that problem or program. In
that case, algorithm helps a lot
2. Alterations and Modifications - If we want to alter or change any logic of the program in
the flowchart, then we have to re-draw the whole flowchart which is very irritating.
Algorithm and Flowchart
7. The Teacher
Algorithm and Flowchart
Basic Symbols used in Flow Chart
– The American National Standard Institute (ANSI) has standardized these given basic flow chart symbols
Terminal
• Terminal symbol is used to indicate the start and end of the program.
• Here is the symbol of terminal:
Input/Output
• A parallelogram is used to represent an input and output representation or operation. Here is
the demo symbol of a input/output used in flowchart:
Start/ End
Input/Output
Algorithm and Flowchart
8. The Teacher
Algorithm and Flowchart
Processing Symbol
• To represent any processing operation in flowchart, we have to use the rectangle symbol.
Here is the demo symbol of rectangle used in drawing flowchart to use storage or arithmetic
operation:
Decision Symbol
• To indicate the step of decision making statement, we have to use diamond shaped box. Here
is the demo symbol of diamond shaped box:
Flow of Lines
• Flow of lines indicates the path of logic flow in a program. Between each boxes used in
flowchart, we have to use lines to indicate where the program flow goes. Here is the demo
symbol of lines flow:
Algorithm and Flowchart
Processing
Decision
9. The Teacher
Algorithm and Flowchart
Example:
• flowchart for addition of two numbers
Algorithm and Flowchart