Selection: IF · Sélection : IF
IF … THEN on one line
- Selection chooses what to run.
- The 2026 guide puts
THENon the same line as the condition. - The block ends at
ENDIF.
IF … THEN sur une seule ligne
- La sélection choisit quoi exécuter.
- Le guide 2026 met
THENsur la même ligne que la condition. - Le bloc se termine à
ENDIF.
DECLARE Age : INTEGER
Age ← 20
IF Age >= 18 THEN
OUTPUT "You may vote"
ENDIF
ELSE is the other path
ELSEruns when the condition isFALSE.- Exactly one of the two blocks runs.
- Nested
IFstatements keep the same shape.
ELSE est l'autre chemin
ELSEs'exécute quand la condition estFALSE.- Exactement l'un des deux blocs s'exécute.
- Les instructions
IFimbriquées conservent la même structure.
DECLARE Mark : INTEGER
Mark ← 72
IF Mark >= 50 THEN
OUTPUT "Pass"
ELSE
OUTPUT "Fail"
ENDIF
TRUE or FALSE — which block runs? · VRAI ou FAUX — quel bloc s'exécute ?
IF runs its THEN block when the test is TRUE; ELSE covers every other case. · IF exécute son bloc THEN quand le test est VRAI ; ELSE couvre tous les autres cas.
Relational operators
=equal,<>not equal,<><=>=.AND,ORandNOTare logic operators. Their operands areBOOLEAN.
Opérateurs relationnels
=égal,<>non égal,<><=>=.AND,ORetNOTsont des opérateurs logiques. Leurs opérandes sontBOOLEAN.
DECLARE N : INTEGER
N ← 7
IF N MOD 2 = 0 THEN
OUTPUT "even"
ELSE
OUTPUT "odd"
ENDIF
AND, OR and NOT
ANDis true only when both tests are true. A mark is in range when it is at least 0 and at most 100.ORis true when either test is true.NOTflipsTRUEandFALSE.- Write the variable on both sides.
Mark >= 0 AND Mark <= 100is the test.Mark >= 0 AND <= 100is not.
AND, OR et NOT
ANDest vrai seulement quand les deux tests sont vrais. Une note est dans la fourchette si elle est au moins 0 et au plus 100.ORest vrai quand l'un ou l'autre test est vrai.NOTinverseTRUEetFALSE.- Écrivez la variable des deux côtés.
Mark >= 0 AND Mark <= 100est le test.Mark >= 0 AND <= 100ne l'est pas.
DECLARE Mark : INTEGER
Mark ← 80
IF Mark >= 0 AND Mark <= 100 THEN
OUTPUT "valid"
ELSE
OUTPUT "invalid"
ENDIF
Watch out
THENstays on theIFline. IGCSE 0478 putsTHENon the following line. Do not mix them.- In a test,
=means "is equal to". Storing a value still uses←. "Pass"and"Fail"need quotes.OUTPUT Passlooks up a name called Pass.
Attention
THENreste sur la ligneIF. IGCSE 0478 metTHENsur la ligne suivante. Ne mélangez pas les styles.- Dans un test,
=signifie « est égal à ». Stocker une valeur utilise toujours←. "Pass"et"Fail"nécessitent des guillemets.OUTPUT Passfait une recherche nommée Pass.
Common mistakes
- Every
IFneeds anENDIF. ELSEbelongs to theIFabove it, not to a nested one, unless you indent it that way.
Erreurs courantes
- Chaque
IFa besoin d'unENDIF. ELSEappartient auIFau-dessus, pas à un imbriqué, sauf si vous l'indentez ainsi.
Now you try
- Read a number and choose with
IF…THEN…ELSE…ENDIF.
À vous maintenant
- Lisez un nombre et choisissez avec
IF…THEN…ELSE…ENDIF.
Read an INTEGER Mark. Output "Pass" when it is at least 50, otherwise "Fail". · Lisez un entier INTEGER Mark. Affichez "Pass" s'il est supérieur ou égal à 50, sinon "Fail".
Click Run to see the output here. · Cliquez sur Exécuter pour voir le résultat ici.
Read an INTEGER N. Output positive when it is greater than 0, otherwise not positive. · Lisez un entier INTEGER N. Affichez positive s'il est supérieur à 0, sinon not positive.
Click Run to see the output here. · Cliquez sur Exécuter pour voir le résultat ici.
Read an INTEGER Mark. Output valid when it is from 0 to · à 100 inclusive, using AND. Otherwise output invalid. · Lisez un entier INTEGER Mark. Affichez valid s'il est compris entre 0 et 100 inclus, en utilisant AND. Sinon affichez invalid.
Click Run to see the output here. · Cliquez sur Exécuter pour voir le résultat ici.