01 · Overview
About Calango
Calango is a pseudolanguage and learning environment for algorithms. Its Portuguese commands keep attention on steps, conditions, and data before learners move on to the syntax of other languages. Materials from the University of Brasília describe its educational use, interpreted execution, and step-by-step debugging.
This reference combines that teaching purpose with the Calango structures described in the sources at the end of the page.
02 · Organization
Algorithm structure
The header starts with algoritmo, followed by a name and semicolon. The main block starts with principal and ends with fimPrincipal. Functions and procedures appear outside this block.
algoritmo boasVindas;
principal
texto nome;
escreva("What is your name?");
leia(nome);
escreval("Hello, ", nome);
fimPrincipalA line beginning with // is a comment. The body can contain declarations and commands; simple statements end with semicolons.
03 · Data
Types, variables, and vectors
Declare a variable by writing its type followed by its name. Basic types include inteiro, real, logico, caracter, and texto. Text literals use double quotes; real numbers use a decimal point; logical values are verdadeiro and falso.
inteiro quantidade;
real preco;
logico disponivel;
caracter inicial;
texto titulo;
inteiro notas[5];
quantidade = 3;
preco = 2.5;
disponivel = verdadeiro;
titulo = "Algorithms";
notas[0] = 10;Vectors are declared by adding dimensions in square brackets after the name. Access an element with brackets as well. The interpreter accepts multiple dimensions; every index must be an integer.
04 · Expressions
Assignment and operators
Assignments use =. Parentheses group operations. The table summarizes arithmetic forms, comparisons, and logical connectors in the documented syntax.
| Category | Operators | Use |
|---|---|---|
| Arithmetic | + - * / \ % mod | Calculations, division, and remainder. |
| Comparison | = == != <> < <= > >= | Compare values. |
| Logical | nao e ou | Negate or combine conditions with AND/OR. |
real total;
total = preco * quantidade;
se (quantidade > 0 e disponivel) entao
escreva("Total: ", total);
fimSeUse mod or % to get a remainder. Precedence follows mathematical and logical priorities; parentheses make long expressions easier to read.
05 · Interaction
Input and output
escreva(...) displays values; escreval(...) adds a line break. Both accept comma-separated expressions. leia(...) reads a value for a variable, and leiaCaracter(...) is the dedicated character input form.
texto nome;
inteiro idade;
escreva("Name: ");
leia(nome);
escreva("Age: ");
leia(idade);
escreval("Hello, ", nome, " — ", idade, " years old.");limpaTela(); clears the output area. Input should match the declared type of its destination variable.
06 · Decisions
Conditions and choice
se begins a conditional block; senaoSe tests another condition and senao defines the final branch. The block ends with fimSe. escolha compares an expression with caso alternatives and can include outroCaso.
se (nota >= 7) entao
escreval("Passed");
senaoSe (nota >= 5) entao
escreval("Review period");
senao
escreval("Not passed");
fimSe
escolha opcao
caso 1
escreval("New exercise");
outroCaso
escreval("Unknown option");
fimEscolhaConditions must produce a logical value. Each caso runs the block associated with its matching value.
07 · Repetition
Enquanto, faça-enquanto, and para
enquanto checks its condition before the body. faca ... enquanto runs first and checks at the end. para traverses a numeric sequence with explicit start, end, and step values.
inteiro i;
i = 1;
enquanto (i <= 3) faca
escreval(i);
i = i + 1;
fimEnquanto
para i de 1 ate 3 passo 1 faca
escreval(i);
fimParainterrompa; immediately exits the innermost loop. Avoid conditions that never become false.
08 · Reuse
Functions, procedures, and parameters
A function declares its return type before its name and ends with fimFuncao. A procedure has no return type and ends with fimProcedimento. Parameters appear in parentheses with type and name; ref marks a reference parameter. retorna returns a function result.
funcao inteiro dobro(inteiro valor)
retorna valor * 2;
fimFuncao
procedimento mostrar(texto mensagem)
escreval(mensagem);
fimProcedimento
principal
escreval(dobro(4));
mostrar("Practice one step at a time");
fimPrincipalCall a routine by name with the arguments it expects. Use reference parameters when a routine should update the variable it receives.
09 · In practice
Complete example
This program reads three grades, calculates the average, and reports a result using a vector, loop, and condition.
algoritmo mediaTurma;
principal
inteiro i;
real notas[3];
real soma;
soma = 0;
para i de 0 ate 2 passo 1 faca
escreva("Grade: ");
leia(notas[i]);
soma = soma + notas[i];
fimPara
se (soma / 3 >= 7) entao
escreval("Passed");
senao
escreval("Keep studying");
fimSe
fimPrincipal10 · Sources
References
- Official Calango repository.
- Algorithm environment — University of Brasília, on interpretation, execution, and educational use.
Examples on this page were written to explain the syntax and do not reproduce long passages from the reference materials.