What is the difference between “while loop” and “do while loop”?
-
We put a semicolon in “while loop” after the while expression as in while(expression); , but semicolon is not allowed after while expression in “do while loop”.
-
Difference between while loop and do while loop is the place where condition is tested.
-
”nested if“ statements cannot be used in while loop, but we can use “nested if” statements in do while loop.
-
'do while loop' causes the program to take more time to execute than while loop.
We can use nested statements in both while loop and do while loop. So, option (3) is incorrect. While and do while loop take some time to execute the program. So, option (4) is also incorrect. We put a semicolon after while (expression) in do while loop, not in while loop. So, option (1) is also incorrect. In while loop, condition is checked following the while loop, but in do while loop, condition is checked at end of loop. Hence, option (4) is the correct answer.