PSeInt Dimension: how to create an array
Creates an array: a row of numbered boxes sharing one name. Use it when you need to keep many values of the same kind, like a class's grades, without inventing a variable for each.
- Group:
- Structures
- Template
Dimension
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 Dimension notas[5] notas[1] <- 18 Escribir notas[1]FinAlgoritmoOutput
Creates 5 slots (notas[1] to notas[5]) and stores 18 in the first.
This is what the console shows when the example runs.
18Common mistake
Depending on the profile, slots start at 1 or at 0.
Some details depend on your school's profile. See the language profiles.
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.
Dimension <arreglo>[<tamano>]Examples that use it
Programs from the example library where it appears, from the simplest to the most complete.
Grade Average
Stores five grades in an array and finds the average and the highest.
BeginnerLinear Search
Finds a name in a list, ignoring upper and lower case.
IntermediateStore Inventory
Records the stock of each product and flags what to restock.
IntermediateBubble Sort
Sorts random numbers by swapping neighbors, and stops as soon as they're in order.
IntermediateSelection Sort
Finds the smallest of the remaining numbers and puts it in its place.
IntermediateInsertion Sort
Inserts each number among the sorted ones, like arranging cards in your hand.
Intermediate
More structures
- Definir
- Escribir
- Escribir Sin Saltar
- Leer
- 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.