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
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 FinParaFinAlgoritmoFlowchart
Each block in the flowchart matches one instruction in the code.
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.
Related examples
Drawing Shapes
Draws a square and a triangle with asterisks.
IntermediateGrade Average
Stores five grades in an array and finds the average and the highest.
BeginnerName Initials
Gets the initials of a full name.
Beginner