Skip to content
EspañolWorkspace →

PSeInt Definir: how to declare variables

Tells the program which variables you'll use and what kind of data each one holds. A variable is like a labelled box: Entero holds whole numbers, Real numbers with decimals, Caracter text, and Logico true or false.

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

definir-declare-variables.psc · 4 lines
Algoritmo Example    Definir edad Como Entero    Definir nombre Como CaracterFinAlgoritmo

Output

Creates the boxes edad and nombre, empty until you store something in them.

This example doesn't print anything to the console.

Common mistake

Definir doesn't give the variable a value; use <- or Leer for that.

In a flowchart

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

Definir edad Como Entero
In the flowchart. Flowchart: a process rectangle reading "Definir edad Como Entero", 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.

Definir · 1 line
Definir <variable> Como Entero

Examples that use it

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

  • Personal Greeting

    Asks for your name and age, and answers with both.

    Beginner
  • Temperature Converter

    Converts degrees Celsius to Fahrenheit and Kelvin.

    Beginner
  • Tip Calculator

    Splits a restaurant bill, tip included.

    Beginner
  • Can I Vote?

    Tells you whether you can vote or how many years you have left.

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