if-else Statement

In C, the if-else statement is used to make decisions in your program. It lets your code choose between two paths: one if a condition is true, and another if it's false.

Syntax:

if (condition) {
    // code runs if condition is true
} else {
    // code runs if condition is false
}

Example:

#include <stdio.h>

int main() {
    int number = 10;

    if (number % 2 == 0) {
        printf("Even number\n");
    } else {
        printf("Odd number\n");
    }

    return 0;
}

As you can see, insted using multiple if statements the if-else syntax makes the code more readable.