Skip to content
ExamplesEspañolWorkspace →

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

countdown.psc · 12 lines
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!"FinAlgoritmo

Flowchart

Each block in the flowchart matches one instruction in the code.

Algoritmo CuentaRegresivaAlgoritmo CuentaRegresivaAlgoritmo CuentaRegresivaDefinir i Como EnteroDefinir i Como EnteroEscribir "Pulsa una tecla para iniciar la cuenta regresiva."Escribir "Pulsa una tecla parainiciar la cuenta regresiva."Esperar TeclaEsperar TeclaPara i <- 5 Hasta 1 Con Paso -1 HacerPara i <- 5 Hasta 1 Con Paso-1Limpiar PantallaLimpiar PantallaEscribir "Despegue en ", i, "..."Escribir "Despegue en ", i,"..."Esperar 1 SegundoEsperar 1 SegundoLimpiar PantallaLimpiar PantallaEscribir "¡Despegue!"Escribir "¡Despegue!"FinAlgoritmoFinAlgoritmo

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.

Open in Codoritmo
  • Times Table

    Prints the multiplication table for the number you choose.

    Beginner
  • Drawing Shapes

    Draws a square and a triangle with asterisks.

    Intermediate
  • Grade Average

    Stores five grades in an array and finds the average and the highest.

    Beginner