Skip to content
EspañolWorkspace →

PSeInt Si Entonces (if statement): how to make a decision

Makes the program take a decision: if the condition is true, it runs the instructions inside; if it's false, it skips them. In the flowchart it's a diamond with two exits.

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

si-entonces-if.psc · 6 lines
Algoritmo Example    edad <- 20    Si edad >= 18 Entonces        Escribir "You can vote"    FinSiFinAlgoritmo

Output

With edad 20 it shows "You can vote"; with 15 it shows nothing.

This is what the console shows when the example runs.

You can vote

In a flowchart

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

edad >= 18SíNo
In the flowchart. Flowchart: a decision diamond with the condition "edad >= 18"; the Sí (yes) exit continues down and the No exit turns right.
Draw the flowchart of your own algorithm →

Template

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

Si · 3 lines
Si <condicion> Entonces  <acciones>FinSi

Examples that use it

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

  • 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
  • Password Check

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

    Beginner
  • Sum Until Zero

    Adds up the numbers you type until you enter a 0.

    Beginner
  • Grade Average

    Stores five grades in an array and finds the average and the highest.

    Beginner
  • Name Initials

    Gets the initials of a full name.

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