CHAPTER 09 / 26

C If Else

Learn how to make decisions using if, else if and else.

01 — Syntax

if (condition) {\n    // code\n} else {\n    // code\n}

02 — Example

#include <stdio.h>

int main() {
    int age = 20;

    if (age >= 18) {
        printf("Adult");
    } else {
        printf("Minor");
    }

    return 0;
}

03 — Important Points

04 — Common Mistakes

05 — Real-World Use

Conditional logic is used in validation, permissions, menus and business rules.

06 — Practice

Create a small program that demonstrates the main idea of C If Else.

▶ Try It Yourself← PreviousNext →All Chapters