Passer au contenu

Lesson 74: Order of the tests

English

The first true test wins

  • In an if ... else if ... else chain, the board checks the tests in order and runs only the first one that is true.
  • So put the strictest test first. 91 is ≥ 40, ≥ 60 and ≥ 80: if score >= 40 comes first, 91 gets a C.
Score Wrong order (≥ 40 first) Right order (≥ 80 first)
21 D D
46 C C
63 C B
91 C A

Se connecter ou créer un compte

IGCSE, A-Level & AP