Explore BrainMass

Explore BrainMass

    While loops versus for loops

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

    1. Explain when you would use a while loop rather than a for loop and vice versa. Provide an example of one such instance.

    2. How are looping statements different from selection statements?

    © BrainMass Inc. brainmass.com October 9, 2019, 10:24 pm ad1c9bdddf

    Solution Preview

    A while loop is intended to run until a particular condition occurs. It is usually not known how many iterations it will take for that condition to be met. A for loop, on the other hand, is usually set to run a known number of times. These are just general rules of thumb that lead to cleaner and ...

    Solution Summary

    This solution explains when it is best to use a while loop versus a for loop. It also explains the difference between a loop and a selection statement.