PSeInt Para (for loop): counting loop with an example
Repeats a known number of times. A counter starts at one value, goes up by one (or by whatever you set with Con Paso), and the loop ends once it passes the final value.
- Group:
- Structures
- Template
Para
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 Para i <- 1 Hasta 5 Hacer Escribir i * 2 FinParaFinAlgoritmoOutput
Shows 2, 4, 6, 8 and 10.
This is what the console shows when the example runs.
246810
Common mistake
Use Para when you know how many rounds; Mientras when it depends on something that happens inside.
In 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.
Para i <- <inicio> Hasta <fin> Hacer <acciones>FinParaExamples that use it
Programs from the example library where it appears, from the simplest to the most complete.
Times Table
Prints the multiplication table for the number you choose.
BeginnerCountdown
A rocket launch countdown that ticks second by second.
BeginnerGrade Average
Stores five grades in an array and finds the average and the highest.
BeginnerName Initials
Gets the initials of a full name.
BeginnerFibonacci Sequence
Prints the first terms of the Fibonacci sequence.
BeginnerDrawing Shapes
Draws a square and a triangle with asterisks.
Intermediate
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.