In the context of while loop and do-while loop in C++, which of the following…
2018
In the context of while loop and do-while loop in C++, which of the following is not true?
- A.
Both the loops are repetitive in nature
- B.
Both are conditional loops
- C.
Both will be executed at least once
- D.
Both are terminated when the condition becomes false
Attempted by 245 students.
Show answer & explanation
Correct answer: C
Both while and do-while loops are conditional and repetitive in nature, and both terminate when the condition becomes false. However, only the do-while loop is guaranteed to execute at least once, because the condition is checked after executing the loop body. In a while loop, the condition is checked before execution, so it may not execute even once. Therefore, statement (c) is not true.