Algorithm and Flowchart for SS2
Algorithm and Flowchart for SS2
Definition Algorithm
Algorithm can be defined as the set of rules and sequential steps that define how a particular problem can be solved in finite and ordered sequence.
Function of Algorithms
An algorithm generally takes some input, carries out a number of effective steps in a finite amount of time, and produces some output.
Characteristics of Algorithms
Every algorithm should have the following five characteristic features
1. Input
2. Output
3. Definiteness
4. Effectiveness
5. Termination
Example1 : Write and algorithm to compute the area and circumference of a cycle given the diameter d. Use the formular
Solution
Step 1: Start
Step 2: Get the diameter d
Step 3: Compute
Step 4: Compute
Step 5: Compute
Step 6: Display the results
Step 7: Stop
Example 2 : Write an algorithm that tells you how to wash dishes
Solution
Step 1: start
Step 2: scrape food off dishes
Steps 3: wash the dishes with soap and water
Step 4: Rinse the dishes
Step 5: Dry them
Step 6: Stop
Example 3: Write an algorithm to evaluate the equation y = a(b-c)^2/d+2
Solution
Step 1: start
Step 2: input the value of a, b, c, d
Step 3: Value of y is to be calculated
Step 4: Calculate the value of b-c and denote f
Step 5: Calculate the square of f
Step 6: Multiply f by a and denote g
Step 7: Calculate the value of d+2 and denote h
Step 8: divide h by g
Step 9: We get the value of y
Step 10: Print y
Step 11: Stop
Definition of Flowchart
This is the graphical representation of steps involved in solving a given problem. More formally, flowchart is a pictorial representation in which symbols are used to show the various operation and decision to be followed in solving a problem.
Some standard symbols used in drawing a program flow chart are:
Comments
Post a Comment