Skip to content
EspañolWorkspace →

Assignment in PSeInt: what the <- arrow means

Stores a value in a variable. Read the arrow <- as "gets": the right side is worked out first and the result goes into the box on the left, replacing whatever was there.

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

assignment-operator.psc · 5 lines
Algoritmo Example    puntos <- 10    puntos <- puntos + 5    Escribir puntosFinAlgoritmo

Output

puntos ends up as 15.

This is what the console shows when the example runs.

15

Common mistake

It isn't a maths equation: puntos <- puntos + 5 means "add 5 to puntos".

Good to know

Besides <-, := is accepted too. Some profiles also let you assign with =, but <- avoids mixing it up with a comparison.

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.

puntos ← puntos + 5
In the flowchart. Flowchart: a process rectangle reading "puntos ← puntos + 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.

Asignar · 1 line
<variable> <- <valor>

Examples that use it

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

  • Temperature Converter

    Converts degrees Celsius to Fahrenheit and Kelvin.

    Beginner
  • Tip Calculator

    Splits a restaurant bill, tip included.

    Beginner
  • Coffee Shop Menu

    Pick a drink from the menu and get the total to pay.

    Beginner
  • Times Table

    Prints the multiplication table for the number you choose.

    Beginner
  • Password Check

    Keeps asking for a password until it has at least 8 characters.

    Beginner
  • Countdown

    A rocket launch countdown that ticks second by second.

    Beginner
See every Variables 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.