Share
Explore BrainMass

Loops

"The do while loop is enough to solve any problem that uses looping and no other repetition structure is required." Discuss this statement by giving examples.

Solution Preview

The

do
{
loop-body
} while (condition)

loop executes the loop body at least once because it checks for the condition later, while

while (condition)
{
loop-body
}

and

for (initialization; condition; condition-related-variable(s)-updation)
{
...

Solution Summary

Do-while loop on its own can not handle all the looping requirements but yes, if used in conjunction with if-statement, it can.

$2.19