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.
- Group:
- Structures
- Template
Repetir
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.
Algoritmo Example Repetir Escribir "Type a positive number" Leer n Hasta Que n > 0FinAlgoritmoOutput
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
Algoritmo Example Repetir Leer clave Hasta Que clave = "1234"FinAlgoritmoOutput
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.
Template
The general form. Replace what's inside < > with your own data.
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.
BeginnerReusable Validation
Validates the email and age on a sign-up form.
IntermediateQuicksort
Picks a pivot, splits smaller from larger values and sorts each side recursively.
AdvancedTic-Tac-Toe
The classic three-in-a-row game for two players.
AdvancedATM
Checks your PIN and lets you check, deposit and withdraw money.
AdvancedContact Book
Add, list and search contacts in a book that grows.
Advanced
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.