PRREL

Semestre 2

Semestre 1

Mémo pour les langages


Instruction Code
Types de base
1, vrai, faux, "chaîne", 'c'
Affectation
a <- 15;
Lecture
lire(variable)
Écriture
écrire("Hello world")
Fonction
fonction nom(Entrée: a : entier, Sortie: entier)
  var b, c, d : entier;
début
  // ...
fin
Procédure
procédure nom(Entrée a : entier)
  VAR b, c, d : entier;
début
  // ...
fin
Condition
si (a > b) alors
  // ...
sinon
  // ...
fin
Boucle pour
pour i allant de 1 à 10 pas 2
  // ...
fin
Boucle tant que
tant que (i <= a) faire
  // ...
fin

Instruction Code
Types de base
1, true, false, "chaîne", 'c'
Affectation
// Pour définir
var a = 10;

// Puis plus loin dans le programme
a = 20;
Lecture
val variable = readInt();  /* Pour lire un entier  */
val variable = readLine(); /* Pour lire une chaîne */
Écriture
println("Hello world")
Fonction
def nom(a: Int) : Int = {
  // ...
}
Condition
if (a > b) {
  // ...
} else {
  // ...
}
Boucle pour
for (a <- 1 to 10) {
  // ...
}
Boucle tant que
while (i <= a) {
  // ...
}