Which loop structure is best suited for scenarios where the number of iterations is known beforehand?

  • do-while loop
  • for loop
  • if-else loop
  • while loop
The for loop is best suited for scenarios where the number of iterations is known beforehand. It's a compact loop structure that allows you to initialize a variable, define a condition, and specify an increment or decrement in a single line. This makes it ideal for loops with a fixed number of iterations, such as iterating through arrays or performing a set number of calculations.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *