Page 129 - Computer - 5
P. 129
Try This Computational Skills
Revise the algorithm for calling your friend to show what needs to be done if no one picks
up the phone when you call. Draw the flowchart for the revised algorithm.
ITERATION OR LOOP
A Loop is a set of instructions which repeats itself continuously until a particular
condition is satisfied. A loop is used when a process needs to be repeated a certain
number of times or until a certain condition is achieved.
Example 5: Draw a flowchart to accept a number and multiply it by itself 10 times.
Start The part of the flowchart given below
represents the loop in the flowchart.
Read N
Count = 1
Product = 1
Product = Product × N
Product = Product × N Count = Count + 1
Count = Count + 1 Is
Count > 10? No
Is
Count > 10? No
The instructions Product = Product × N
Yes and Count = Count + 1 are repeated until
Print Product the value of Count is less than or equal
to 10. When it becomes greater than 10,
Stop
the loop ends.
When a loop is used in a flowchart, a value called Counter is used to keep track of
the number of times the loop is to run. The value Count in the above example is a
counter which checks how many times the loop has run.
Example 6: Draw a flowchart to calculate the average marks of each of the 40 students
in a class and display the names of the students who got more than 80% marks.
127