Skip to content
EspañolWorkspace →

PSeInt profile UPSIN

These are the rules of the UPSIN profile, explained simply, with an example that follows them and opens in Codoritmo with one click.

Open in Codoritmo with this profile

Opens this page's example with the UPSIN profile already switched on.

How its author describes it

The profile's original text, in Spanish, as distributed with PSeInt.

Perfil para la asignatura "Programacion Estructurada" del programa académico Ingeniería Biomédica de la Universidad Politécnica de Sinaloa-UPSIN (enviado por el Ing. Cesar Hazzel Gonzalez Rojas).

In short

What changes compared with Codoritmo's default profile:

  • Every variable must be declared with Definir
  • The Para counter is protected
  • Every statement must end with a semicolon
  • Entonces, Hacer and endings such as FinSi must be written in full
  • You can assign with = as well as <-
  • Arrays start at 0
  • Array sizes must be fixed numbers
  • No Para Cada (for each) loop
  • Repetir only ends with Hasta Que
  • No text functions such as Longitud or Subcadena

All of its rules

Marked rules differ from Codoritmo's default profile; everything else behaves the same.

Variables

How they are declared and when they can be used.

Declare variables with DefinirDiffers from default
Required. Before using a variable you must declare it with its type, for example Definir edad Como Entero. That includes the counter of every Para.
Give a value before use
Not checked. It's still good practice to give every variable a value before using it.
Protected Para counterDiffers from default
Inside a Para you can't change the counter, and once the loop ends the counter has no value, so don't use it afterwards.
Accents and ñ in names
Allowed: a variable can be called año or posición.

Writing style

Punctuation, closing words and how values are assigned.

Semicolon at the endDiffers from default
Required. Every statement ends in ;, as in Escribir "Hola";. Lines that open or close a structure (Si, FinSi, FinPara) don't take one.
Relaxed syntaxDiffers from default
Strict: write every structure in full, with Entonces, Hacer and one-word endings such as FinSi and FinMientras.
Assign with =Differs from default
Allowed: besides x <- 5 you can write x = 5. Inside a condition, = is still a comparison.

Operators and conditions

How comparisons are written and text is put together.

Word operators
You can write Y, O, NO and MOD (and, or, not, remainder) as well as their symbols &, |, ~ and %.
Plain-language conditions
Accepts conditions such as x Es Par (is even), x Es Mayor Que 5 (is greater than 5) or x Es Divisible Por 3.
Join text with +
Allowed: "Hola, " + nombre makes a single piece of text.

Arrays

Where indexes start and how the size is set.

First array indexDiffers from default
Arrays start at 0: after Dimension notas[3] the slots are notas[0], notas[1] and notas[2].
Array size from a variableDiffers from default
Not allowed: the size in Dimension must be a fixed number, such as Dimension datos[10].
Resize arrays
You can change the size of an existing array with Redimensionar.

Loops and Segun

Which ways of repeating and choosing between cases it accepts.

Para Cada loopDiffers from default
Not available: go through arrays with a Para and an index.
Repetir … Mientras QueDiffers from default
A Repetir loop can only end with Hasta Que condition (until).
Para counting down
If the start is greater than the end, Para counts down one by one even without Con Paso -1.
Segun with whole numbers
The value a Segun checks can also be text, with options such as "a".

Subroutines and text functions

Which extra tools you get to organise the program.

Your own subroutines and functions
You can write your own SubProceso or Funcion to split the program into parts.
Text functionsDiffers from default
Not available: this profile has no Longitud, Subcadena, Mayusculas, Minusculas or Concatenar.

An example that follows these rules

It works out the average of three marks. It's written for this profile, and the comments point out what changes compared with the default. We checked it with Codoritmo's interpreter using these same rules.

PerfilUPSIN.psc · 38 lines
// Example written with the rules of the UPSIN profile// Every statement ends with a semicolon// Strict syntax: Entonces, Hacer and FinSi always in fullAlgoritmo PerfilUPSIN    // This profile requires every variable to be declared with Definir    Definir notas, suma, i Como Entero;    Definir promedio Como Real;    Definir nombre Como Caracter;    // The array size must be a fixed number    Dimension notas[3];    // Arrays start at 0: the slots are 0, 1 and 2    notas[0] <- 8;    notas[1] <- 9;    notas[2] <- 7;    // This profile also lets you assign with =    suma = 0;    // No Para Cada: the array is read with an index    Para i <- 0 Hasta 2 Hacer        // Inside the Para you can't change i        suma <- suma + notas[i];    FinPara    promedio <- suma / 3;    nombre <- "Ana";    Escribir "Hi, ", nombre;    Escribir "Average: ", promedio;    Si promedio >= 7 Y promedio <= 10 Entonces        Escribir "Passed";    SiNo        Escribir "Failed";    FinSi    Si suma Es Par Entonces        Escribir "The sum is even: ", suma;    SiNo        Escribir "The sum is odd: ", suma;    FinSi    // Longitud, Mayusculas and the other text functions aren't available    // Repetir can only end with Hasta QueFinAlgoritmo

What it prints

This is the example's real output, run with the UPSIN profile.

Hi, Ana
Average: 8
Passed
The sum is even: 24
Open in Codoritmo with this profile

Examples that touch these rules

They open with the default profile; switch to yours from the editor's bottom bar.

  • Grade Average

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

    Beginner
  • Factorial and Power

    Functions that compute a factorial and a power.

    Intermediate
  • Leap Year

    Applies the calendar rules to tell whether a year is a leap year.

    Intermediate

Profiles and their descriptions come from the bin/perfiles folder of PSeInt, where each teacher or school contributed their own. Codoritmo ships them unchanged so you can practise with the same rules.

Codoritmo is an independent project inspired by PSeInt and compatible with its syntax; it is not PSeInt and is not affiliated with its authors.