PSeInt profile UNSa Oran
These are the rules of the UNSa Oran profile, explained simply, with an example that follows them and opens in Codoritmo with one click.
Opens this page's example with the UNSa Oran profile already switched on.
How its author describes it
The profile's original text, in Spanish, as distributed with PSeInt.
Perfil para la cátedra de Programación de las carreras Licenciatura en Análisis de Sistemas (LAS), Tecnicatura Universitaria en Programación (TUP) y Tecnicatura en Informática de Gestión (TIG) que se dictan en la Sede Regional Orán de la Universidad Nacional de Salta (a cargo del Prof. Asociado. Ing. Ruben Maza).
In short
What changes compared with Codoritmo's default profile:
- The Para counter is protected
- Every statement must end with a semicolon
- You can assign with = as well as <-
- Text can't be joined with +
- Arrays start at 0
- No SubProceso or Funcion of your own
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 Definir
- Optional. You can use a variable without declaring it: its type comes from the first value you store in it.
- 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
Parayou 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ñoorposición.
Writing style
Punctuation, closing words and how values are assigned.
- Semicolon at the endDiffers from default
- Required. Every statement ends in
;, as inEscribir "Hola";. Lines that open or close a structure (Si,FinSi,FinPara) don't take one. - Relaxed syntax
- Accepts handy variants:
Fin Sias two words, optionalEntoncesandHacer,Mientras QueandDesdein loops, and values inEscribirseparated by spaces. - Assign with =Differs from default
- Allowed: besides
x <- 5you can writex = 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,NOandMOD(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) orx Es Divisible Por 3. - Join text with +Differs from default
- Not allowed: to show several values together, separate them with commas in
Escribir.
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 arenotas[0],notas[1]andnotas[2]. - Array size from a variable
- Allowed: you can read
nand then writeDimension datos[n]. - 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 loop
- Available:
Para Cada nota de notas Hacergoes through every slot of an array. - Repetir … Mientras Que
- A
Repetirloop can end withHasta Que condition(until) orMientras Que condition(while). - Para counting down
- If the start is greater than the end,
Paracounts down one by one even withoutCon Paso -1. - Segun with whole numbers
- The value a
Segunchecks 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 functionsDiffers from default
- Not allowed: the whole program goes inside
Algoritmo … FinAlgoritmo. - Text functions
- Available:
Longitud,Subcadena,Mayusculas,MinusculasandConcatenar(length, substring, upper case, lower case, join).
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.
// Example written with the rules of the UNSa Oran profile// Every statement ends with a semicolon// This profile has no SubProceso or Funcion: everything goes inside AlgoritmoAlgoritmo PerfilUNSaOran 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; Para i <- 0 Hasta 2 Hacer // Inside the Para you can't change i suma <- suma + notas[i]; FinPara promedio <- suma / 3; nombre <- "Ana"; // + doesn't join text: Escribir separates values with commas 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; FinSiFinAlgoritmoWhat it prints
This is the example's real output, run with the UNSa Oran profile.
Hi, Ana Average: 8 Passed The sum is even: 24
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.
BeginnerCountdown
A rocket launch countdown that ticks second by second.
BeginnerCount Vowels
Counts the vowels, spaces and other characters in a text.
Intermediate