Computer Applications
State one similarity and one difference between while and for loop.
Java Iterative Stmts
ICSE 2009
Answer
Similarity — Both for and while are entry-controlled loops
Difference — 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.
Answered By
Related Questions
Distinguish between while and do-while loop.
State one difference and one similarity between while loop and do-while loop.
Give two differences between Step loop and Continuous loop.
Predict the Output of the following Java program:
class dkl { public static void main(String args[]) { int i; for(i = -1;i<10;i++) { System.out.println(++i); } } }