Skip to content
EspañolWorkspace →

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.

Template
Dimension
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.

dimension-arrays.psc · 5 lines
Algoritmo Example    Dimension notas[5]    notas[1] <- 18    Escribir notas[1]FinAlgoritmo

Output

Creates 5 slots (notas[1] to notas[5]) and stores 18 in the first.

This is what the console shows when the example runs.

18

Common 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.

Dimension notas[5]
In the flowchart. Flowchart: a process rectangle reading "Dimension notas[5]", with one arrow in and one arrow out.
Draw the flowchart of your own algorithm →

Template

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

Dimension · 1 line
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.

    Beginner
  • Linear Search

    Finds a name in a list, ignoring upper and lower case.

    Intermediate
  • Store Inventory

    Records the stock of each product and flags what to restock.

    Intermediate
  • Bubble Sort

    Sorts random numbers by swapping neighbors, and stops as soon as they're in order.

    Intermediate
  • Selection Sort

    Finds the smallest of the remaining numbers and puts it in its place.

    Intermediate
  • Insertion Sort

    Inserts each number among the sorted ones, like arranging cards in your hand.

    Intermediate
See every Arrays 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.