Discussions

22Feb 2022 by
Please answer the question below and respond to the student post. Please prove two separate paragraphs for each.
Discussion:Under what circumstances would you use a for loop rather than a while loop?
matthew’s post:A for loop is used when you want to explicitly define the number of iterations within a loop. If a developer knows that they need to make X number of iterations, then a for loop would be a better solution than a while loop. Conversely, a while loop is useful when you don’t know how many iterations are needed. You can break a while loop when some condition is met, as opposed to specifying the number of iterations.

Place Order