Skip to content · ⁨Saltar al contenido⁩

Add up to five · ⁨Sumar hasta cinco⁩

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.

Español

Sumar hasta cinco

Utilice un bucle while para sumar 1 + 2 + 3 + 4 + 5 en total. Al finalizar, total debe ser igual a 15.

Cada vuelta del bucle cambian dos cosas: el valor acumulado de total y el contador n. Si olvida actualizar el contador, el bucle nunca terminará; si olvida actualizar el total, este quedará vacío al final.

Log in or create account · ⁨Iniciar sesión o crear cuenta⁩

IGCSE, A-Level & AP