Algorithm
Its representation of a program logic in the simple and understandable formatits an order sequence of a well-define and unambiguous instructions which perform some task and halt at finite time.
- Total number of steps used in algorithm should be finite
- It should halt at finite time
- Instructions must be clear and unambiguous
- The algorithm should have zero or more input but at-least have one output
- Every step must be basic & essential
There are three types of algorithm operations.
- Sequential operations:- In this instruction are executed in sequence
- Branching/conditional operation:-It is control structure in which it ask question true/false and act according to the answer.
- Iterative/looping operation:-It is control structure in which it repeat the execution of block instruction
1) Sequential operation:
write an algorithm to calculate area of rectangle.
Algorithm
- Accept the value of length i.e. L
- Accept the value of breadth i.e. B
- Calculate area i.e. A=L*B
- Print Area i.e. A
- Stop procedure
write an algorithm to find smallest number out of two number.
Algorithm
- Accept two numbers i.e.a,b
- Check if a<b? If yes go to Step 3 otherwise go to Step5
- Print a is smallest number
- Stop procedure
- Print b is smallest number
- Stop procedure
write an algorithm to find out factorial of given number.
Algorithm
- Accept N
- I=1
- FACT=1
- FACT=FACT*I
- I=I+1
- If I<=N go to Step 4
- Print FACT
- Stop procedure
No comments:
Post a Comment