which of the following loops will execute the body of loop even when condition controlling the loop is initially false?
The loop that will execute its body even when the controlling condition is initially false is the do-while loop.
Direct answer
In a do-while loop, the body runs first and the condition is checked afterward , so the loop body is guaranteed to execute at least once, even if the condition starts out false.
So, for the question:
“Which of the following loops will execute the body of loop even when condition controlling the loop is initially false?”
the correct option is:
- a) do-while ✅
Quick illustration
Example in C/Java-style syntax:
c
int x = 0;
do {
printf("This will print once.\n");
} while (x > 0);
Here, x > 0 is false from the start, but the message still prints one
time because the condition is checked only after the body executes.
By contrast, both while and for check their conditions before entering
the loop, so if the condition is initially false, their bodies may not run
even once.
TL;DR
- Executes at least once even if condition is initially false: do-while loop.
Information gathered from public forums or data available on the internet and portrayed here.