Algorithm and Flowchat

Definition Algorithm

Algorithm can be defined as a set of rules and sequential steps that define how a particular problem can be solved in finite and ordered sequences.

Function of Algorithms

An algorithm generally takes some input, carries out several effective steps in a finite amount of time, and produces some output.

Characteristics of Algorithms

Every algorithm should have the following five characteristic features
i. Input
ii. Output
iii. Definiteness
iv. Effectiveness
v. Termination

Example1: Write an algorithm to compute the area and circumference of a cycle given the diameter d. Use the formular A= πr^2 and C= 2πr Solution
Step 1: Start
Step 2: Get the diameter d
Step 3: Compute r=(d/2)
Step 4: Compute A= πr^2
Step 5: Compute C= 2πr
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
The rule of BODMAS is to be followed to effectively evaluate thise equation
Step 1: start
Step 2: Input the values of a, b, c, d
Step 3: The 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 the steps involved in solving a given problem. More formally, a flowchart is a pictorial representation in which symbols are used to show the various operation and decisions to be followed in solving a problem.
Some standard symbols used in drawing a program flow chart are:

Rules for Drawing Flowchart


i. Every flowchart must terminate, that is, it must have a starting and ending points.
ii. The Direction of flow should be from left to right or top to bottom.
iii. Maintain consistent spacing between symbols
iv. Use the correct symbol for each step
v. Keep it simple and clear.
Example 1: Draw a flow chart to print the area of a 10cm square

Comments

Popular posts from this blog

90 Objective Examination Questions in Major Subjects

Complete Computer Studies/ICT Curriculum for JSS 1 to SSS 3

JSS One Objective Questions in Computer Studies/Information Technology