1. What is the difference between a while loop and a for loop?
Ans. A for loop is used when the number of iterations is known, while while loop is used when the number of iterations is unknown.
2. What will be the output of the following for loop?
for (int i = 10; i >= 1; i /= 2) { System.out.print(i + ” “); }
Ans. 10 5 2 1.
