Why use a do-while loop?

Vivek Yadav
1 min readOct 4, 2019

--

In most computer programming languages, a do while loop is a control flow statement that executes a block of code at least once, and then repeatedly executes the block, or not, depending on a given boolean condition at the end of the block.

Unlike for and while loops, which test the loop condition at the top of the loop, the do…while loop in programming checks its condition at the bottom of the loop.

BUT, Why to choose DO-WHILE

Following code demonstrate why to use do-while loop

Write like this

do{

//.....
// 100000 lines of code!
//.....

} while(i%10);

Not like this

//.....
// 100000 lines of code!
//.....

while(i%10){

//.....
// 100000 lines of code!
//.....

}

Connect with me on: Github Twitter LinkedIn Instagram Youtube Patreon

#HappyCoding #flutter #bloc #optimisation #tutorial

**Subscribe for upcoming posts. Thanks for reading. Let me know what you think about this post.

--

--

Vivek Yadav
Vivek Yadav

Written by Vivek Yadav

Writer , Speaker, Instructor and Flutter Dev

No responses yet