+ 1

do .. while is used for what?? What do.. while function?

30th Aug 2019, 8:53 AM
anastasya aulia
anastasya aulia - avatar
3 odpowiedzi
+ 2
do-while is while except do-while would execute at least once. You can always use either while or do-while. For me, it's just a style of programming. Comparation: do { cout << "Hello"; } while(1+1==3) //Output: Hello while(1+1==3) { cout << "Hello" } //No output.
30th Aug 2019, 9:09 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 2
If you need a loop that will execute at least once regardless of the condition inside the brackets being “true” or “false” or you need the condition to be checked at the end of each loop, then you use the “do...while” loop.
30th Aug 2019, 9:54 AM
Kireii
Kireii - avatar
0
A 'do... while' loop is the exact same as a regular 'while' loop but it will always execute at least once. Int x = 1; do { cout << "hi"; }while(x = 0) Here, even though the condition is false, it runs the code then checks the condition, so it executes only one time.
31st Aug 2019, 2:27 AM
UrBoyO
UrBoyO - avatar