Skip to content
ExamplesEspañolWorkspace →

Times Table

Prints the multiplication table for the number you choose.

Level
Beginner
Topic:
Loops
Concepts:
Input & output
Para
Open in Codoritmo

Run, change and debug this example in your browser.

What you'll learn

The Para ... Hasta ... Hacer loop repeats a block a fixed number of times. The variable i moves from 1 to 10 on its own, one step per pass.

Code

times-table.psc · 8 lines
Algoritmo TablaMultiplicar    Definir n, i Como Entero    Escribir "¿Qué tabla quieres ver?"    Leer n    Para i <- 1 Hasta 10 Hacer        Escribir n, " x ", i, " = ", n * i    FinParaFinAlgoritmo

Flowchart

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

Algoritmo TablaMultiplicarAlgoritmo TablaMultiplicarAlgoritmo TablaMultiplicarDefinir n, i Como EnteroDefinir n, i Como EnteroEscribir "¿Qué tabla quieres ver?"Escribir "¿Qué tabla quieresver?"Leer nLeer nPara i <- 1 Hasta 10 HacerPara i <- 1 Hasta 10Escribir n, " x ", i, " = ", n * iEscribir n, " x ", i, " = ", n* iFinAlgoritmoFinAlgoritmo

Sample run

This is what the program shows when it runs. The answers typed by the user are highlighted.

¿Qué tabla quieres ver?User answer: 77 x 1 = 77 x 2 = 147 x 3 = 217 x 4 = 287 x 5 = 357 x 6 = 427 x 7 = 497 x 8 = 567 x 9 = 637 x 10 = 70

Challenge

Also ask how far the table should go instead of always stopping at 10.

Show hint

Read another variable and use it in place of the 10 in the Para.

Open in Codoritmo
  • 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
  • Name Initials

    Gets the initials of a full name.

    Beginner