Skip to content
EspañolWorkspace →

PSeInt Repetir Hasta Que (repeat-until loop), with an example

Repeats a group of instructions and checks the condition at the end of each round, so it always runs at least once. Ideal for asking until the answer is valid.

Template
Repetir
Open it in Codoritmo

Opens the editor with this example loaded. Run it step by step and watch the flowchart.

Worked example

A complete algorithm, ready to copy and run.

repetir-hasta-que-do-while.psc · 6 lines
Algoritmo Example    Repetir        Escribir "Type a positive number"        Leer n    Hasta Que n > 0FinAlgoritmo

Output

Keeps asking while you type 0 or negatives.

This is what the console shows when the example runs. What the user types is highlighted.

Type a positive numberUser answer: -3Type a positive numberUser answer: 0Type a positive numberUser answer: 7

Another example

repetir-hasta-que-do-while.psc · 5 lines
Algoritmo Example    Repetir        Leer clave    Hasta Que clave = "1234"FinAlgoritmo

Output

Keeps asking for the code until you type 1234.

This is what the console shows when the example runs. What the user types is highlighted.

User answer: 0000User answer: 1234

In a flowchart

This is how it appears in a flowchart, with the same shapes Codoritmo draws.

…n > 0NoSí
In the flowchart. Flowchart: the body first, then a decision diamond with the condition "n > 0" below it; on No it repeats, on Sí (yes) it leaves.
Draw the flowchart of your own algorithm →

Template

The general form. Replace what's inside < > with your own data.

Repetir · 3 lines
Repetir  <acciones>Hasta Que <condicion>

Examples that use it

Programs from the example library where it appears, from the simplest to the most complete.

  • Password Check

    Keeps asking for a password until it has at least 8 characters.

    Beginner
  • Reusable Validation

    Validates the email and age on a sign-up form.

    Intermediate
  • Quicksort

    Picks a pivot, splits smaller from larger values and sorts each side recursively.

    Advanced
  • Tic-Tac-Toe

    The classic three-in-a-row game for two players.

    Advanced
  • ATM

    Checks your PIN and lets you check, deposit and withdraw money.

    Advanced
  • Contact Book

    Add, list and search contacts in a book that grows.

    Advanced
See every Repetir example →

More structures

Codoritmo is an independent, open-source project inspired by PSeInt and compatible with its syntax. It is not affiliated with the PSeInt project. Official PSeInt website.