Lesson 8 / 36
If ... Else
Run code only when a condition holds.
if / else if / else
Chains are checked top to bottom; the first true branch wins.
if (score >= 90) {
printf("A\n");
} else if (score >= 80) {
printf("B\n");
} else {
printf("C or below\n");
}Ternary
int max = (a > b) ? a : b; — a compact if/else that produces a value.
switch
switch matches one value against discrete cases. Forgetting break causes fall-through to the next case.