Skip to content
EspañolWorkspace →

PSeInt Para Cada (for-each loop): walk through an array

Walks through an array from start to end; on each round the variable takes the next slot's value, so you don't have to handle positions.

Template
Para Cada
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.

para-cada-for-each.psc · 9 lines
Algoritmo Example    Dimension notas[3]    notas[1] <- 15    notas[2] <- 9    notas[3] <- 18    Para Cada nota De notas Hacer        Escribir nota    FinParaFinAlgoritmo

Output

Shows every grade in the array, in order.

This is what the console shows when the example runs.

15918

In a flowchart

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

Para Cada nota De notas…
In the flowchart. Flowchart: a Para loop hexagon reading "Para Cada nota De notas", the body below it and an arrow back to the hexagon on every pass.
Draw the flowchart of your own algorithm →

Template

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

Para Cada · 3 lines
Para Cada item De <coleccion> Hacer  <acciones>FinPara

Examples that use it

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

  • Shopping List

    Adds items to a list that grows until you type FIN.

    Advanced
See every Para Cada 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.