PSeInt has a small vocabulary — which is exactly why it is such a good first tool — but students often forget the exact form of an instruction: was it Hasta Que or Hasta? Does Para need Hacer? Which function returns the length of a text? This page answers those questions. It lists every common PSeInt instruction with its English meaning, its syntax and a short example you can run in the online editor.
The syntax shown is PSeInt's flexible default profile. Some courses use stricter profiles (for example, mandatory variable declarations); everything here works in those too, as long as you declare your variables.
Quick translation table
| PSeInt | English | Purpose |
|---|---|---|
Algoritmo / FinAlgoritmo | Algorithm / end | Program frame (also Proceso / FinProceso) |
Definir … Como … | Define … as … | Declare variables and their type |
Leer | Read | Input from the keyboard |
Escribir | Write | Output to the screen |
<- | Assign | Store a value in a variable |
Si … Entonces … SiNo … FinSi | If … then … else | Two-way decision |
Segun … Hacer … FinSegun | Switch / case | Multi-way decision |
Mientras … Hacer … FinMientras | While … do | Loop checked at the start |
Repetir … Hasta Que … | Repeat … until | Loop checked at the end |
Para … Hasta … Con Paso … Hacer | For … to … step | Counting loop |
Dimension | Dimension | Create an array |
Funcion / SubProceso | Function / subroutine | Reusable block of code |
Program structure
Algoritmo Ejemplo
// instrucciones
FinAlgoritmo
The name after Algoritmo cannot contain spaces. Functions and subprocesses are written outside the main block, before or after it. Instructions go one per line; a trailing semicolon is optional, and you can place two short instructions on one line by separating them with ;.
Variables and data types
Definir
Definir contador, total Como Entero
Definir precio Como Real
Definir nombre Como Caracter
Definir encontrado Como Logico
Types: Entero (integer), Real (decimal; Numero and Numerico are synonyms), Caracter (text; also Texto and Cadena) and Logico (boolean). Variable names start with a letter and may contain letters, digits and underscores.
Assignment
contador <- 0
precio <- 19.99
nombre <- "Ana"
encontrado <- Falso
total <- contador * 2 + 5
The arrow <- is the standard form; the flexible profile also accepts =. Reading the arrow as "receives" helps: contador receives 0.
Input and output
Escribir
Escribir "Hola"
Escribir "Total: ", total
Escribir Sin Saltar "Ingrese un valor: "
Items separated by commas are printed one after another with no space in between. Sin Saltar keeps the cursor on the same line, which is handy for prompts. Imprimir and Mostrar are accepted synonyms.
Leer
Leer edad
Leer ancho, alto
Leer waits for the user to type a value and press Enter. With several variables, it asks for each value in turn. If the variable was declared as a number and the user types text, PSeInt reports an error.
Operators
| Category | Operators | Example → result |
|---|---|---|
| Arithmetic | + - * / ^ | 2 ^ 3 → 8, 7 / 2 → 3.5 |
| Remainder | MOD or % | 17 MOD 5 → 2 |
| Relational | = <> < > <= >= | 5 <> 3 → Verdadero |
| Logical | Y (&), O (|), NO (~) | x > 0 Y x < 10 |
| Text | + joins strings | "Hola " + nombre |
Order of evaluation, from first to last: parentheses, power, unary minus, * / MOD, + -, relational operators, NO, Y, O. When in doubt, add parentheses.
Conditionals
Si – Entonces – SiNo
Si temperatura > 30 Entonces
Escribir "Hace calor"
SiNo
Escribir "No hace calor"
FinSi
The SiNo part is optional. Conditions can be combined with Y, O and NO, and Si blocks can be nested inside each other.
Segun
Segun opcion Hacer
1:
Escribir "Nuevo"
2, 3:
Escribir "Editar o borrar"
De Otro Modo:
Escribir "Opción no válida"
FinSegun
Segun compares one value against a list of options. Several values can share a branch when separated by commas, and De Otro Modo handles everything else. More detail in the conditionals guide.
Loops
Mientras
Mientras saldo > 0 Hacer
saldo <- saldo - cuota
FinMientras
Checks the condition before each repetition; the body may run zero times.
Repetir – Hasta Que
Repetir
Escribir "Clave:"
Leer clave
Hasta Que clave = 1234
Checks the condition after each repetition, so the body always runs at least once. It stops when the condition becomes true.
Para
Para i <- 1 Hasta 10 Con Paso 2 Hacer
Escribir i
FinPara
Counts from the start value to the end value. Con Paso sets the increment and can be negative to count down; if omitted, the step is 1. See the loops guide for patterns such as counters and accumulators.
Arrays
Dimension notas[30]
Dimension tablero[8, 8]
notas[1] <- 9.5
tablero[2, 3] <- 1
Dimension creates an array with the given size; two sizes create a matrix. In the default profile the first position is 1. Our arrays and matrices guide covers filling, searching and sorting them.
Functions and subprocesses
A SubProceso groups instructions you want to reuse. A Funcion is the same thing that also returns a value: you name the return variable before the function name.
Funcion resultado <- Cuadrado(n)
resultado <- n * n
FinFuncion
SubProceso Separador
Escribir "----------"
FinSubProceso
Algoritmo UsarFunciones
Separador
Escribir "El cuadrado de 7 es ", Cuadrado(7)
Separador
FinAlgoritmo
Parameters are passed by value by default (the function gets a copy). Write Por Referencia after a parameter so the function can modify the caller's variable — the classic example is swapping two values. Arrays are always passed by reference.
SubProceso Intercambiar(a Por Referencia, b Por Referencia)
Definir aux Como Real
aux <- a
a <- b
b <- aux
FinSubProceso
Algoritmo Prueba
Definir x, y Como Real
x <- 1
y <- 2
Intercambiar(x, y)
Escribir x, " ", y
FinAlgoritmo
Built-in mathematical functions
| Function | Returns | Example |
|---|---|---|
RC(x) or RAIZ(x) | Square root | RC(81) → 9 |
ABS(x) | Absolute value | ABS(-4) → 4 |
TRUNC(x) | Integer part | TRUNC(7.9) → 7 |
REDON(x) | Nearest integer | REDON(7.5) → 8 |
AZAR(n) | Random integer from 0 to n-1 | AZAR(6) + 1 → a die roll |
ALEATORIO(a, b) | Random integer from a to b | ALEATORIO(1, 100) |
LN(x), EXP(x) | Natural log, ex | EXP(1) → 2.718… |
SEN COS TAN | Trigonometry (radians) | SEN(PI / 2) → 1 |
ASEN ACOS ATAN | Inverse trigonometry | ATAN(1) → 0.785… |
PI | The constant π | 2 * PI * r |
Built-in text functions
| Function | Returns | Example |
|---|---|---|
LONGITUD(s) | Number of characters | LONGITUD("Hola") → 4 |
MAYUSCULAS(s) | Upper case | MAYUSCULAS("pse") → "PSE" |
MINUSCULAS(s) | Lower case | MINUSCULAS("INT") → "int" |
SUBCADENA(s, i, j) | Characters from position i to j | SUBCADENA("PSeInt", 1, 3) → "PSe" |
CONCATENAR(a, b) | Joined text | CONCATENAR("Ho", "la") → "Hola" |
CONVERTIRANUMERO(s) | Number from text | CONVERTIRANUMERO("42") → 42 |
CONVERTIRATEXTO(x) | Text from number | CONVERTIRATEXTO(3.5) → "3.5" |
Positions in SUBCADENA start at 1 in the default profile (some strict profiles start at 0).
Other useful instructions
Borrar Pantalla(orLimpiar Pantalla) clears the console.Esperar Teclapauses until the user presses a key.Esperar 2 Segundos(orMilisegundos) pauses for a fixed time — nice for simple animations and countdowns.
Comments and documentation
Everything after // on a line is a comment. Use comments to explain why something is done, not to repeat the code. A short header comment with the purpose of the algorithm, the author and the date is a good habit for assignments:
// Calcula el promedio de un curso y la cantidad de aprobados.
// Autor: Ana Pérez — 2026
Algoritmo PromedioCurso
// ...
FinAlgoritmo
Syntax profiles
The desktop PSeInt lets each course choose a profile that adjusts the rules. Typical settings include:
- whether every variable must be declared with
Definirbefore use; - whether arrays and string positions start at 0 or at 1;
- whether instructions must end with a semicolon;
- whether
=may be used for assignment or only<-.
If a program that works for a classmate fails for you with a strange syntax error, compare your profiles first. Writing in the strictest style — declare everything, use <-, close every block explicitly — produces code that works under any profile.
Common error messages and what they mean
| Situation | Likely cause | Fix |
|---|---|---|
| A block is reported as not closed | A Si, Para or Mientras without its Fin… | Format the code and look for the misaligned block |
| Variable without a value | Reading a variable before assigning it | Initialise it (x <- 0) or read it first |
| Type mismatch | Text stored in a number, or a decimal in an Entero | Check the declaration and the quotes; use TRUNC or REDON |
| Index out of range | Array position below 1 or above its size | Check the loop limits, especially with v[i + 1] |
| Condition is not logical | A number used where a true/false value is needed | Compare it: Si x <> 0 Entonces |
| Division by zero | Divisor equal to 0 at run time | Check the divisor with Si before dividing |
Reserved words you cannot use as names
Keywords such as Si, Para, Leer, Fin…, the type names, Verdadero, Falso and the built-in function names are reserved. Using them as variable names leads to confusing errors, so avoid names like si, leer or longitud. A safe convention is to use descriptive nouns: cantidadAlumnos, precioUnitario, esValido.
Translating PSeInt to real languages
Every structure in this reference has a direct equivalent in mainstream languages. Escribir becomes print in Python or System.out.println in Java; Si … SiNo becomes if … else; Mientras becomes while; Para becomes for; Dimension v[10] becomes an array or list. The desktop PSeInt can perform this translation automatically, which is a great way to see the same algorithm written in a professional language once you've mastered the logic.
Putting it together
This program uses almost every category in this reference: declarations, input, a loop, a condition, a function and text functions.
Funcion r <- EsVocal(c)
c <- MINUSCULAS(c)
r <- c = "a" O c = "e" O c = "i" O c = "o" O c = "u"
FinFuncion
Algoritmo ContarVocales
Definir frase Como Caracter
Definir i, vocales Como Entero
Escribir "Escriba una frase:"
Leer frase
vocales <- 0
Para i <- 1 Hasta LONGITUD(frase) Hacer
Si EsVocal(SUBCADENA(frase, i, i)) Entonces
vocales <- vocales + 1
FinSi
FinPara
Escribir "La frase tiene ", vocales, " vocales"
FinAlgoritmo
Type a sentence such as "Programar es divertido" and the program reports 8 vowels. (Accented vowels such as "á" are not counted by this simple version — a good exercise is to add them.)
Style rules that make programs readable
- Indent the body of every block by four spaces.
- Use descriptive names:
precioFinalinstead ofpf. - Declare all variables at the top of the algorithm.
- Prompt before every
Leer. - Add a comment above each logical part of a long algorithm.
Frequently asked questions
What is the difference between SubProceso and Funcion?
In current PSeInt they are the same construct: Funcion, SubProceso and SubAlgoritmo are interchangeable keywords. By convention, a block that returns a value (with resultado <- Nombre(…) in its header) is called a function.
Can I use = instead of <- ?
In the flexible profile, yes. Inside a condition, = means comparison. Using <- for assignment avoids confusion and works in every profile.
Is there a "Retornar" instruction?
Standard PSeInt returns values through the variable named in the function header. Our online editor additionally accepts Retornar valor as a shortcut, but for maximum compatibility use the return variable.
Why does PSeInt say my variable has no value?
You are reading a variable before assigning anything to it. Give it an initial value — for example suma <- 0 before a loop.