PSeInt profile CECyTEA
These are the rules of the CECyTEA profile, explained simply, with an example that follows them and opens in Codoritmo with one click.
Opens this page's example with the CECyTEA profile already switched on.
How its author describes it
The profile's original text, in Spanish, as distributed with PSeInt.
Perfil para los alumnos del Colegio de Estudios Científicos y Tecnológicos del Estado de Aguascalientes, Plantel Ferrocarriles. Usado para el submódulo "Desarrolla software utilizando programación estructurada" para los alumnos del profesor L. I. Rodrigo López Peña (RoLP).
In short
What changes compared with Codoritmo's default profile:
- The Para counter is protected
- No accents or ñ in variable names
- Every statement must end with a semicolon
- Only the symbols & | ~ % work as operators
- No conditions like Es Par: comparisons use operators
- Array sizes must be fixed numbers
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 namesDiffers from default
- Not allowed in variable or subroutine names: write
anioorposicion. Accented keywords such asSegúnstill work.
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 =
- Not allowed: you assign only with
<-;=is only for comparing.
Operators and conditions
How comparisons are written and text is put together.
- Word operatorsDiffers from default
- Symbols only:
&instead of Y (and),|instead of O (or),~instead of NO (not) and%instead of MOD. - Plain-language conditionsDiffers from default
- Doesn't accept them: write the comparison with operators, such as
x MOD 2 = 0orx > 5. - Join text with +
- Allowed:
"Hola, " + nombremakes a single piece of text.
Arrays
Where indexes start and how the size is set.
- First array index
- Arrays start at 1: after
Dimension notas[3]the slots arenotas[1],notas[2]andnotas[3]. - Array size from a variableDiffers from default
- Not allowed: the size in
Dimensionmust be a fixed number, such asDimension 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 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 functions
- You can write your own
SubProcesoorFuncionto split the program into parts. - 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 CECyTEA profile// Every statement ends with a semicolonAlgoritmo PerfilCECyTEA // Variable names have no accents or ñ // The array size must be a fixed number Dimension notas[3]; notas[1] <- 8; notas[2] <- 9; notas[3] <- 7; suma <- 0; Para i <- 1 Hasta 3 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; // No word operators: & instead of Y, % instead of MOD Si promedio >= 7 & promedio <= 10 Entonces Escribir "Passed"; SiNo Escribir "Failed"; FinSi // Es Par isn't accepted: the condition uses operators Si suma % 2 = 0 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 CECyTEA 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.
BeginnerFactorial and Power
Functions that compute a factorial and a power.
IntermediateCount Vowels
Counts the vowels, spaces and other characters in a text.
Intermediate