Skip to content
EspañolWorkspace →

PSeInt SubProceso: how to write and call a procedure

Groups instructions under a name so you can use them whenever you want, like a recipe. It can receive data (parameters) to work with.

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

subproceso-procedure.psc · 7 lines
SubProceso Saludar(nombre)    Escribir "Hola, ", nombreFinSubProcesoAlgoritmo Example    Saludar("Ana")FinAlgoritmo

Output

Then Saludar("Ana") shows "Hola, Ana".

This is what the console shows when the example runs.

Hola, Ana

Common mistake

A Por Referencia parameter lets the subprocess change the original variable.

In a flowchart

This is how it appears in a flowchart, with the same shapes Codoritmo draws.

Saludar("Ana")
In the flowchart. Flowchart: a subprocess call rectangle reading "Saludar("Ana")", 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.

SubProceso · 3 lines
SubProceso Nombre(<parametro>)  <acciones>FinSubProceso

Examples that use it

Programs from the example library where it appears, from the simplest to the most complete.

  • 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
  • Counting Sort

    Counts how many times each value appears, without comparing numbers.

    Intermediate
  • Binary Search

    Finds a value in a sorted array by halving the range every step.

    Intermediate
  • Linear vs. Binary Search

    Counts the comparisons each search needs on the same sorted list.

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