What is the purpose of a do-while loop?

前端 未结 5 2084
说谎
说谎 2021-01-17 08:59

I know what do does, and how it cooperates with the while loop, but won\'t a while loop code be the same, whether or not the do is there?

5条回答
  •  遥遥无期
    2021-01-17 09:53

    The difference is with "do-while" loop will be executed at least one time. With "while" loop with false condition the loop body will not be executed.

提交回复
热议问题