Explaining the best techniques of problem-solving
A flowchart is a pictorial representation of an algorithm. It is often used by programmers as a program – planning tool for organizing a sequence of steps necessary to solve a problem by a computer. It uses boxes of different shapes to denote different types of instructions. The actual instructions are written within these boxes using clear and concise statement. These boxes are connected by solid lines having arrow marks to indicate the flow of operation, that is, the exact sequence in which the instructions are to be executed. The process of drawing a flowchart for an algorithm is often referred to as flowcharting.
Need for Flowchart Symbols:
A flowchart uses boxes of different shapes to denote different types of instructions. The communication of program Logic through flowchart is made easier by the use of symbols, which have a standardized meaning. This is because as long as everyone uses the same basic shapes, others can readily interpret the logic.
Basic Flowchart Symbols:
Only a few symbols are needed to indicate the necessary operations in a flowchart. These basic symbols have been standardized by ANSI (American National Standard Institute). They are shown below:
- Terminal: The terminal symbol is used to indicate the beginning (start) and end (stop) and pauses (halt) in the program logic flow.
- Input/Output: The input/output symbol is used to denote any function of an input/output device in the program. If there is a program instruction to input data from a disk, tape, terminal or any other type of input device that will be indicated in the flowchart with an input/output symbol.
- Processing: A processing symbol is used in a flowchart to represent arithmetic and data movement instruction.
- Decision Symbol: The decision symbol is used in a flowchart to indicate a point at which a decision has to be made, and a branch to one of two or more alternative points is possible.
- Flowlines: Flow lines with arrowheads are used to indicate the flow of operation that is the exact sequence in which the instructions are to be executed. The normal flow of flowchart is from top to bottom and left to right.
- Connectors: Connectors symbol is represented by a circle, and a letter or digit is placed within the circle to indicate the link. This symbol represents an entry from or an exit to another part of the flowchart.
Example: Flowchart to print the sum of two numbers A and B.
The term algorithm is often used to refer to the logic of a program. It is a step by step description of how to arrive at the solution of the given problem. In order to qualify as an algorithm, a sequence of instructions must possess the following characteristics:
1. Each and every instruction should be precise and unambiguous.
2. Each instruction should be such that it can be performed in a finite time.
3. One or more instructions should not be repeated infinitely.
4. After performing the instructions that are the algorithm terminates the desired results must be obtained.
Representation of Algorithm:
There are various ways in which an algorithm can be represented. Programmers normally use one or more of the following ways to represent their algorithms:
1. As programs,
2. As pseudo codes,
3. As flowcharts
When an algorithm is represented in the form of programming language, it becomes a program. Hence, any program is an algorithm, although the reverse is not true.
Example 1: An algorithm to calculate and print a total number of students who passed in first division.
Step 1: Initialize Total_First_Division and Total_Marksheets_checked to zero.
Step 2: Take the mark sheet of the next student.
Step 3: Check the division column of mark sheet to see if it is first. If no go to step 5
Step 4: Add 1 to Total_First_Division
Step 5: Add I to Total_Marksheets_checked.
Step 6 : Is Total_Marksheets_checked = 50 ? If no, go to step 2.
Step 7: Print TotaI_First_Division
Step 8: Stop
Example 2: An algorithm to print the sum of two numbers
Step 1: Take two variables A and B.
Step 2: Input the values of A and B.
Step 3 : Compute sum = A + B
Step 4: print sum
Step 5: Stop