while和do while循环之间的区别

Here you will get to know about difference between while and do while loop.

在这里,您将了解while和while循环之间的区别。

Both while and do while loops are used to execute set of statements multiple times. But there are some differences between them in terms of syntax and working that I have discussed below.

while和do while循环都用于多次执行语句集。 但是它们之间在语法和工作方式方面存在一些差异,我下面将进行讨论。

while和do while循环之间的区别 (Difference between while and do while Loop)

while循环语法 (while loop syntax)

while(condition){
	loop body;
}

做while循环语法 (do while loop syntax)

do{
	loop body;
}while(condition);
while loopdo while loop
It is entry controlled loop. That means condition is checked at the start of loop body.It is exit controlled loop. That means condition is checked at the end of loop body.
Loop body is not executed if condition is false.Loop body is executed once even if condition is false.
Generally not used for making menu driven programs.Generally used for making menu driven programs.
while循环 做while循环
它是入口控制的循环。 这意味着在循环体开始时检查条件。 这是退出控制循环。 这意味着在循环体的末端检查条件。
如果条件为假,则不执行循环体。 即使条件为假,循环体也会执行一次。
通常不用于制作菜单驱动程序。 通常用于制作菜单驱动程序。

翻译自: https://www.thecrazyprogrammer.com/2018/03/difference-between-while-and-do-while-loop.html

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值