QP School

Full Version: if-else statements in C
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Conditional statements allow you to execute different code blocks based on certain conditions.

int num = 10;
if (num > 0) {
    printf("Positive\n");
} else if (num < 0) {
    printf("Negative\n");
} else {
    printf("Zero\n");
}