tags:

views:

353

answers:

5

what is the minimum number of times the while loop is executed?

Is it zero?

Not talking about DO

+7  A: 

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.

Ngu Soon Hui
+1  A: 
 while (  condition ) {
    /* stuff */
 }

Unless condition is true stuff will not happen

djna
+1  A: 

if it's

while(cond) {
    // code
}

then minimum count is 0

BUT if it's

do {
    // code
} while(cond)

then minimum count is 1

Kamil Klimek
+1  A: 

Yes, if the while's condition isn't satisfied at the first time, the loop is executed zero times.

Igor Oks
A: 

While (not Do-While) will execute zero times if the condition is not met.

chrishibler