Definition of Algorithm
Algorithm is a step by step solution to a given problem. Sequence of steps written in order to carry out some particular task. Each step of an algorithm is written in english.
Various charaterstics of an algorithm are
- The algorithm must have definite start and
- An algorithm may accept zero or more inputs
- An algorithm must produce atleast one output
- The steps of an algorihtm must be simple, easy to understand and unambigous.
- Each step must be precise and
- The algorihtm must contain finite number of
Example:
Algorithm 1: Algorihtm for finding of area of traingle
Step 1: start
Step 2: Read base and height of traingle Step 3: Calulate area of traingle
Step 4: print area of traingle Step 5: stop
Algorithm 2: Algorihtm for finding of sum and average of given three numbers
Step 1: start
Step 2: Read three numbers i.e. A, B and C
Step 3: find sum of three numbers i.e. sum=A+B+C
Step 4: find average of three numbers i.e. average=sum/3 Step 4: print sum and average
Step 5: stop