Algorithm
The term algorithm is used to refer the logic of program.
It is step by step description of how to arrive at the
solution of a given problem. It may be define as a sequence of instruction
design in a manner that if the instructions are executed in the specified
sequence then the desired result will be obtained.
Characteristics of Good Algorithm:
There are some characteristic of good algorithm.
i. Finiteness: it means that every algorithm should have finite number of steps.
ii. Definiteness: every algorithm should have definite processor to be followed.
iii. Effectiveness: every algorithm should be clear and should completed in finite number of time.
iv. Input: there
should be one or more input.
v. Output: There should be one or more output.
Step to be followed to write an algorithm:
1>
Start
2>
Identify the input & output variables
3>
Input the value of input variable
4>
Calculate the output according to the problem
5>
Output the result
6>
Stop
Example:
Write an algorithm to add two numbers.
1.
Start
2.
Let the input variables are a&b and output
variable c.
3.
Input the value of a & b.
4.
C= a+b.
5.
Output the value of c
6.
Stop
Question 1
Write an algorithm to find the average of give number.
1.
Start
2.
Let the input variable are a,b,c,d,e and output
variable Avg.
3.
Input the value of a,b,c,d,e
4.
Avg=(a+b+c+d+e)/5
5 .
Output the value of Avg
6.
Stop
No comments:
Post a Comment