Skip to content
EspañolWorkspace →

PSeInt Retornar: end a function with a value

Ends the function right there and hands the given value back to whoever called it.

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

retornar-return.psc · 10 lines
Funcion r <- Maximo(a, b)    Si a > b Entonces        Retornar a    FinSi    Retornar bFinFuncionAlgoritmo Example    Escribir Maximo(3, 9)FinAlgoritmo

Output

Maximo(3, 9) gives back 9.

This is what the console shows when the example runs.

9

In a flowchart

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

Retornar b
In the flowchart. Flowchart: a process rectangle reading "Retornar b", 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.

Retornar · 1 line
Retornar <valor>

Examples that use it

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

  • Linear vs. Binary Search

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

    Intermediate
  • Factorial and Power

    Functions that compute a factorial and a power.

    Intermediate
  • Reusable Validation

    Validates the email and age on a sign-up form.

    Intermediate
  • Prime Numbers

    Finds every prime number up to a limit.

    Intermediate
  • GCD and LCM

    Computes the greatest common divisor and the least common multiple.

    Intermediate
  • Quicksort

    Picks a pivot, splits smaller from larger values and sorts each side recursively.

    Advanced
See every Functions 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.