What is the two main difference between while loop and do-while loop? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the two main difference between while loop and do-while loop?

21st Mar 2017, 11:58 AM
Sidhant Singh
Sidhant Singh - avatar
3 Answers
+ 7
(while) - entry control loop i.e. starts executing if the condition is initially true. (do while) - exit control loop i.e. executes and checks the condition. That's why a do while loop always executes at least once.
21st Mar 2017, 12:02 PM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 1
the main difference is that the do-while, executes the block of code at least once, even if the condition is false.
21st Mar 2017, 12:02 PM
Welliton Malta
Welliton Malta - avatar
0
ok
21st Mar 2017, 12:05 PM
Sidhant Singh
Sidhant Singh - avatar