C has no boolean type in its original form. A condition is an integer expression, and zero is false while everything else is true - which is why if (ptr) is idiomatic for "not null" and why a function returning -1 for failure is true in an if. C99 added <stdbool.h> with bool, true and false, and new code should use it.
Two mistakes in this area compile without complaint. The first is = where == was meant: if (x = 5) assigns 5 to x and then tests 5, which is always true. Writing the constant first - if (5 == x) - makes the mistake a syntax error, and -Wall warns about it either way. The second is the dangling else: without braces, an else binds to the nearest unmatched if, which may not be the one your indentation suggests. Always use braces, even for one statement.
switch compares one integer expression against constant cases and falls through to the next case unless you break. That fall-through is occasionally what you want, for grouping cases, and is otherwise a bug - annotate a deliberate one with a comment so the next reader knows. default catches everything else; include it.
The ternary condition ? a : b is an expression, so it can appear where a statement cannot - initialising a const, or inside a function call. Nesting them more than once makes code that nobody can read.
#include <stdio.h>
#include <stdbool.h>
int main(void)
{
int score = 87;
/* Braces always. Without them an else binds to the nearest if,
whatever the indentation claims. */
if (score >= 90) {
printf("A\n");
} else if (score >= 80) {
printf("B\n");
} else {
printf("C or below\n");
}
/* = instead of == compiles and is always true. Writing the constant
first turns the typo into a syntax error. */
int x = 3;
if (x = 5) { } /* assigns, then tests 5: always true */
if (5 == x) { } /* and "if (5 = x)" would not compile */
/* Zero is false, everything else is true. There is no bool in C89,
which is why this reads naturally. */
char *p = NULL;
if (!p) { printf("p is null\n"); }
char grade = 'B';
switch (grade) {
case 'A':
case 'B': /* deliberate fall-through: grouped cases */
printf("pass\n");
break; /* without this, 'C' runs too */
case 'C':
printf("borderline\n");
break;
default: /* always include one */
printf("unknown grade\n");
break;
}
/* An expression, so it works where a statement cannot. */
const char *label = (score >= 50) ? "pass" : "fail";
printf("%s\n", label);
return 0;
}