Countdown
A rocket launch countdown that ticks second by second.
- Level
- Beginner
- Topic:
- Loops
- Concepts:
- Para
- Screen & waiting
Open in Codoritmo
Run, change and debug this example in your browser.
What you'll learn
A Para loop with Con Paso -1 counts backwards. Esperar Tecla, Esperar 1 Segundo and Limpiar Pantalla control the pace and what stays on screen.
Code
Algoritmo CuentaRegresiva Definir i Como Entero Escribir "Pulsa una tecla para iniciar la cuenta regresiva." Esperar Tecla Para i <- 5 Hasta 1 Con Paso -1 Hacer Limpiar Pantalla Escribir "Despegue en ", i, "..." Esperar 1 Segundo FinPara Limpiar Pantalla Escribir "¡Despegue!"FinAlgoritmoFlowchart
Each block in the flowchart matches one instruction in the code.
Sample run
This program doesn't ask for input: this is what it shows when it runs.
Pulsa una tecla para iniciar la cuenta regresiva.Despegue en 5...Despegue en 4...Despegue en 3...Despegue en 2...Despegue en 1...¡Despegue!
Challenge
Ask which number the countdown should start from.
Show hint
Read a number and use it as the starting value of the Para instead of 5.
Related examples
Times Table
Prints the multiplication table for the number you choose.
BeginnerDrawing Shapes
Draws a square and a triangle with asterisks.
IntermediateGrade Average
Stores five grades in an array and finds the average and the highest.
Beginner