Algorithm is a finite sequence of instructions for solving a problem.
Importance of algorithm:
→ It is simple and easy to understand.
→ It has no hard and fast rules for writing an algorithm.
→ It does not require prior knowledge of programming during writing algorithms.
Algorithm to calculate area of rectangle
Step 1: Start
Step 2: Input L,B
Step 3: Calculate A=L*B
Step 4: Output A
Step 5: Stop
Flowchart is a pictorial form of an algorithm. It uses meaningful symbols to represent different types of instructions.
Importance of Flowchart:
→ It is very efficient tool for solving logical and mathematical problems.
→ It shows the types of instruction whether; an instruction is input/output, process or logical.
→ It is easy for converting flowchart into program codes.
→ It is easy for testing and maintenance.
Flowchart to calculate area of rectangle
Algorithm to find perimeter of a rectangular object Step 1: Start Step 2: Input L,B Step 3: Calculate P=2*(L+B) Step 4: Output P Step 5: Stop
Algorithm to find sum of any five non-negative number Step 1: Start Step 2: Input A,B,C,D,E Step 3: Calculate SUM=A+B+C+D+E Step 4: Output SUM Step 5: Stop
Flowchart to find the volume of a box:
Flowchart to find the sum of any five positive numbers
Algorithm to find greatest number among four different numbers
Step 1: Start
Step 2: Input three different numbers as a,b and c
Step 3:Check is A>B AND A>C AND A>D?
3.1 If yes,Print A
3.2 If no, goto step 4
Step 4: Check is B>A AND B>C AND B>D?
4.1 If yes, Print B
4.2 If no, goto step 5
Step 5: Check is C>A AND C>B AND C>D?
5.1 If yes, Print C
5.2 If no, Print D
Step 6: Stop
Flowchart to find greatest number among four different numbers