Criteria to be followed by an Algorithm The following is the criteria to be followed by an algorithm:
• Input: There should be zero or more values which are to be supplied.
• Output: At least one result is to be produced.
• Definiteness: Each step must be clear and unambiguous.
• Finiteness: If we trace the steps of an algorithm, then for all cases, the algorithm must terminate after a finite number of steps.
• Effectiveness: Each step must be sufficiently basic that a person using only paper and pencil can in principle carry it out. In addition, not only each step is definite, it must also be feasible
Example
Let us try to develop an algorithm to compute and display the sum of two numbers
1. Start
2. Read two numbers a and b
3. Calculate the sum of a and b and store it in sum
4. Display the value of sum
5. Stop
#include<stdio.h>
Comments
Post a Comment