The do loop differs from the while loop in that a the while

The do loop differs from the while loop in that

a. the while loop will always execute the body of the loop at least once

b. the do loop will always execute the body of the loop at least once

c. the do loop will continue to loop while condition in the while statement is false and the while loop will continue to loop while the condition in the while statement is true

d. the while loop will continue to loop while condition in the while statement is false and the do loop will continue to loop while the condition in the while statement is true

e. none of the above, there is absolutely no difference between the two types of loops

a. the while loop will always execute the body of the loop at least once

b. the do loop will always execute the body of the loop at least once

c. the do loop will continue to loop while condition in the while statement is false and the while loop will continue to loop while the condition in the while statement is true

d. the while loop will continue to loop while condition in the while statement is false and the do loop will continue to loop while the condition in the while statement is true

e. none of the above, there is absolutely no difference between the two types of loops

Solution

Answer is b.

do loop structure is as shown below

do{

}while()

So it executes the block atleast once and then checks the condition

Hence, the do loop will always execute the body of the loop at least once

The do loop differs from the while loop in that a. the while loop will always execute the body of the loop at least once b. the do loop will always execute the

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site