PSeInt Leer: read input from the user
Pauses the program and waits for the person to type something; whatever they type is stored in the variable. This lets your program work with different data each time.
- Group:
- Structures
- Template
Leer
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 Escribir "How old are you?" Leer edad Escribir edadFinAlgoritmoOutput
If you type 15, the variable edad becomes 15.
This is what the console shows when the example runs. What the user types is highlighted.
How old are you?User answer: 1515
Common mistake
Use Escribir first to say what you expect; otherwise the person won't know what to type.
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.
Leer <variable>Examples that use it
Programs from the example library where it appears, from the simplest to the most complete.
Personal Greeting
Asks for your name and age, and answers with both.
BeginnerTemperature Converter
Converts degrees Celsius to Fahrenheit and Kelvin.
BeginnerTip Calculator
Splits a restaurant bill, tip included.
BeginnerCan I Vote?
Tells you whether you can vote or how many years you have left.
BeginnerCoffee Shop Menu
Pick a drink from the menu and get the total to pay.
BeginnerTimes Table
Prints the multiplication table for the number you choose.
Beginner
More structures
- Definir
- Dimension
- Escribir
- Escribir Sin Saltar
- Assignment (<-)
- Si Entonces (if)
- Si / SiNo (if-else)
- Segun (switch)
- Mientras (while)
- Repetir Hasta Que (do-until)
- Repetir Mientras Que (do-while)
- Para (for)
- Para Cada (for each)
- Limpiar Pantalla
- Esperar
- Esperar Tecla
- SubProceso
- SubAlgoritmo
- Funcion (function)
- Retornar (return)
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.