Skip to content · ⁨コンテンツへスキップ⁩

Add up to five · ⁨5まで足し合わせる⁩

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.

日本語

5まで足し合わせる

while ループを使って 1 + 2 + 3 + 4 + 5 を total に加算します。total は最終的に 15 となるべきです。

ループの繰り返しごとに2つの変化が生じます:累積値の total と counter(カウンタ)の n です。カウンタを忘れるとループは終わらず、合計値を忘れると結果が空になってしまいます。

Log in or create account · ⁨ログインまたはアカウント作成⁩

IGCSE, A-Level & AP