Page 124 - Computer - 5
P. 124
Let us consider some examples for writing an algorithm.
Example 1: Write an algorithm to buy a cake from a bakery shop.
Step 1 Step 2 Step 3
Take money. Go to a bakery shop. Select a cake.
Step 4 Step 5 Step 6
Get the cake packed properly. Pay the bill for the cake. Return home with the cake.
Example 2: Write an algorithm to find the average of five numbers.
Algorithm Working of algorithm
Step 1: Get the five numbers. 7, 11, 8, 12, 17
Step 2: Add the numbers to get their sum. 7 + 11 + 8 + 12 + 17 = 55
Step 3: Divide the sum by 5. 55 ÷ 5 = 11
Step 4: Display the result as average. 11
Knowledge Discovery Subject Enrichment
Algorithms are written in a stepwise manner, with each step involved with one specific
action.
Try This Computational Skills
Write an algorithm to accept the length and breadth of a rectangle and calculate its area.
122