An Algorithm is the set of well-defined instruction in a sequence to solve a given problem in a programming language.
An Algorithm should always have a clear starting and stopping point.
Qualities of a good algorithm
- The Input and output should be precisely defined.
- Each step in an algorithm should be clear & unambiguous.
- An algorithms should be effective among many different ways to solve & execute a problem.
- An algorithm should not have computer code, Instead the algorithm should be written in such a manner that it can be used in co-similar programming languages.
Examples Of Algorithm In Programming
- Write an algorithm to add two numbers entered by user.
Step-2: Declaration of the variables number1, number2 & sum.
Step-3: Read the values of number1 and number2.
Step-4: Add number1 & number2 & assign result to the sum.
Step-5: Display the sum.
Step-6: Finally Stop.
2) Write an algorithm to find the greatest among the three different numbers entered by user.
Step-2: Declaration of the variables m,n & p.
Step-3: Read the values of variables m,n & p.
Step-4: Check is a>b,
Display that a is the largest number.
Display that c is the largest number.
Display that b is the largest number.
Display that c is the greatest number.