Skip to content

Add up to five · ⁨加到五⁩

English

Add up to five

Use a while loop to add 1 + 2 + 3 + 4 + 5 into total. total should end as 15.

Two things change every time round: the running total, and the counter n. Miss the counter and the loop never ends; miss the total and it ends with nothing in it.

中文

加到五

用 while 循环把 1 + 2 + 3 + 4 + 5 累加进 total。total 最后应该是 15。

每一轮有两样东西在变:累加的 total 和计数器 n。少了计数器,循环停不下来;少了累加,循环结束时里面什么也没有。

Log in or create account · ⁨登录或创建账户⁩

IGCSE, A-Level · ⁨IGCSE、A-Level⁩ & AP · ⁨与 AP⁩