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.
- Group:
- Structures
- Template
Si
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.
Algoritmo Example edad <- 20 Si edad >= 18 Entonces Escribir "You can vote" FinSiFinAlgoritmoOutput
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 voteIn a flowchart
This is how it appears in a flowchart, with the same shapes Codoritmo draws.
Template
The general form. Replace what's inside < > with your own data.
Si <condicion> Entonces <acciones>FinSiExamples 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.
BeginnerCoffee Shop Menu
Pick a drink from the menu and get the total to pay.
BeginnerPassword Check
Keeps asking for a password until it has at least 8 characters.
BeginnerSum Until Zero
Adds up the numbers you type until you enter a 0.
BeginnerGrade Average
Stores five grades in an array and finds the average and the highest.
BeginnerName Initials
Gets the initials of a full name.
Beginner
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.