Question:What is the difference between while and do-while loop? 

Answer While loop: 1. Initialization->condition->statement/increment is the sequence of while loop execution.
2. The while loop begins with a termination condition and keeps looping until the termination condition is met.
3. If the condition is not true, none statement will execute within the loop because condition is checked before executing the statement.

Do-while loop: 1. Initialization->statement/interment->condition is the sequence of do-while loop execution.
2. Unlike the while loop, the do-while loop always executes statements in the loop in the first iteration of the loop.
3. As the condition is checked after executing statements in the loop, at least once loop statements will be executed within the loop even if condition is false. 


Deprecated: html_entity_decode(): Passing null to parameter #1 ($string) of type string is deprecated in D:\webserver\www\vcampusbd_com_https\answers\column_answer_two.php on line 128
+ Report
Total Preview: 1213
What is the difference between while and do-while loop?
Copyright © 2024. Powered by Intellect Software Ltd