Back to Course
Control Flow

Conditional Statements in C: if, if..else, Nested if

What are Conditional Statements?

Conditional statements let a program make decisions and execute different code blocks based on whether a condition is true or false.

The if Statement

if (marks >= 40) {
    printf("Pass");
}

The if...else Statement

if (marks >= 40) {
    printf("Pass");
} else {
    printf("Fail");
}

Nested if

if (marks >= 90) {
    printf("Grade A");
} else {
    if (marks >= 75) {
        printf("Grade B");
    }
}

Nested if statements place one if inside another to test multiple layered conditions.

Ready to master real-world C Programming development?

Learn C Programming hands-on with mentor-led, live sessions.

Explore Course