Computer Applications
Distinguish between for and while loop
Java Iterative Stmts
76 Likes
Answer
- 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.
- 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