Question

Describe a situation where a for loop would be preferred over a while loop. Describe a...

  1. Describe a situation where a for loop would be preferred over a while loop. Describe a situation where a while loop would be preferred over a for loop. How is a for loop similar to a while loop? In what way or ways are for and while loops different?
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:-

situation where a for loop would be preferred over a while loop:-

if the number of iteration is known then for loop is preferable.

situation where a while loop would be preferred over a for loop.

if the number of iteration is unknown then while loop is preferable.

How is a for loop similar to a while loop

for loop and while loop both are used for iterating the element we can use both the loop in same way also.

In what way or ways are for and while loops different?

if the value of the number of iteration is known then for loop is helpful. when number of iteration is un pridictable then we can use while. this is a major difference.

Add a comment
Know the answer?
Add Answer to:
Describe a situation where a for loop would be preferred over a while loop. Describe a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT