Explore BrainMass
Share

Loops

This content was STOLEN from BrainMass.com - View the original, and get the solution, here!

"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.

© BrainMass Inc. brainmass.com September 24, 2018, 1:18 pm ad1c9bdddf - https://brainmass.com/computer-science/programming-languages/457631

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