Question 5 of 16beginner💡 UnderstandShort Answer2 marks

Give an example of a loop that is to be executed a certain number of times.

Correct Answer

An example of a loop that is executed a certain number of times is: "Clap your hands five times." In this example, the action of clapping is repeated exactly five times, which represents a fixed number of iterations.

In programming terms, Example 4.8 demonstrates this concept. The pseudocode accepts 5 numbers and finds their average. A counter called "count" keeps track of the number of times the loop has been repeated. The loop continues WHILE count < 5, and after every iteration, the value of count is incremented by 1 until it performs the set number of repetitions. This is a clear example where the number of iterations is known beforehand.

Exercise: EXERCISE | Q: 4 | (Page 23)
For More Understanding

Explanation

The textbook provides both real-world and programming examples of loops with fixed iterations. 'Clap your hands five times' is a simple real-world example. Example 4.8 shows a programming example where a counter variable tracks the exact number of repetitions (5 times) to accept numbers and compute their average. The key concept is that the number of iterations is predetermined and known before the loop begins execution.