KnowledgeBoat Logo
|
LoginJOIN NOW

Computer Applications

Distinguish between for and while loop

Java Iterative Stmts

76 Likes

Answer

  1. for loop is a suitable choice when we know the number of iterations beforehand. while loop is helpful in situations where numbers of iterations is not known.
  2. Omitting the condition in for loop will lead to an infinite loop whereas if condition is not provided in while loop, it will cause a compilation error.

Answered By

53 Likes


Related Questions