热门

最新

红包

立Flag

投票

同城

我的

发布
melanie_fay
暖暖萱
4 年前
truemelanie_fay

Both, for and while loops can be used to execute a block of code for multiple times.

It is common to use the for loop when the number of iterations is fixed. For example, iterating over a fixed list of items in a shopping list.

The while loop is used in cases when the number of iterations is not known and depends on some calculations and conditions in the code block of the loop.
For example, ending the loop when the user enters a specific input in a calculator program.

CSDN App 扫码分享
分享
评论
点赞
打赏
  • 复制链接
  • 举报
下一条:
求助!avaiLable里没有项目咋回事?谢谢啦
立即登录