What is the significance of updating loop control variable in while statements
Answers
Answered by
14
Answer:
The variable count is initialized, tested, and changed as the loop executes. It is an ordinary int variable, but it is used in a special role. The role is that of a loop control variable. Not all loops have loop control variables, however.
Answered by
1
Answer:
The significance of updating the loop control variable in while statements is that it helps to terminate the loop.
Explanation:
- Loops are used when a part of the code is to be repeated n number of times.
- But the loop has to be terminated after a certain number of iterations in order to avoid an infinite loop.
- Hence, we use a control variable to keep a count of the number of iterations.
- We use the control variable in a conditional statement.
- When the condition is satisfied, the loop is broken and the control of the program is sent out of the loop.
Therefore, updating the loop control variable is useful to break the iterations.
#SPJ3
Similar questions
Physics,
2 months ago
Math,
2 months ago
Math,
5 months ago
India Languages,
10 months ago
Science,
10 months ago