if (A>B)
if (A>10)
printf ("premier choix \n"); else if (B<10)
printf ("deuxième choix \n"); else
if (A==B) printf ("troisième choix \n");
else printf ("quatrième choix \n");
a) Copiez la séquence d'instructions en utilisant des tabulateurs
pour marquer les blocs if - else appartenant ensemble.
if (A>B)
if (A>10)
printf ("premier choix \n");
else if (B<10)
printf ("deuxième choix \n");
else if (A==B)
printf ("troisième choix \n");
else
printf ("quatrième choix \n");
b) Le résultat:
| "premier choix" | apparaît pour (A>B) et (A>10) | ||
| "deuxième choix" | apparaît pour (10 |
||
| "troisième choix" | apparaît pour (10 |
||
| 10>10 impossible | |||
| A>B et A=B impossible | => | "troisième choix" n'apparaît jamais | |
| "quatrième choix" | apparaît pour (10 |
||
| 10>10 impossible | => | "quatrième choix" n'apparaît jamais |
c)
On n'obtient pas de réponses pour (A
B).
Si (A>B) alors la construction if - else if - ... - else garantit
que toutes les combinations sont traitées et fournissent un résultat.