what is the minimum number of times the while loop is executed?
Is it zero?
Not talking about DO
what is the minimum number of times the while loop is executed?
Is it zero?
Not talking about DO
Depends on how you write it.
If while(){}
, then yes, the minimum number of times is 0.
If do{}while()
;, then the minimum number of times is 1
If not talking about the DO, then it's 0.
while ( condition ) {
/* stuff */
}
Unless condition is true stuff will not happen
if it's
while(cond) {
// code
}
then minimum count is 0
BUT if it's
do {
// code
} while(cond)
then minimum count is 1
Yes, if the while's condition isn't satisfied at the first time, the loop is executed zero times.
While
(not Do-While
) will execute zero times if the condition is not met.