Module 06: Control Flow & Decision Making Structures

Duration: 2.5 Hours • Core Control
1. if-else Logic 1 / 4

Conditional Branching & Dangling Else

How C evaluates truthiness (0 = False, Non-zero = True)

In C, there is no separate boolean hardware type in original C89; any integer other than 0 is considered True, and 0 is False.

dangling_else_resolved.c
// Dangling Else Rule: An 'else' always binds to the closest unmatched preceding 'if'
if (score >= 50) {
    if (score >= 90) {
        printf("Grade: A*\\n");
    }
} else {
    printf("Grade: Fail\\n"); // Explicit braces guarantee correct binding
}