C if...else Statement

#include <stdio.h>

int main() {
    int number = 10;

    if (number > 0) {
        printf("The number is positive.\n");
    } else {
        printf("The number is not positive.\n");
    }

    return 0;
}

Explanation:

  1. #include <stdio.h>: Includes the standard input-output header file.

  2. int main() {: The starting point of the program execution. main() is the function that gets executed when the program runs.

  3. int number = 10;: Declares an integer variable named number and assigns it the value 10.

  4. if (number > 0) { ... } else { ... }: This is an if...else statement. It checks the condition inside the parentheses (number > 0). If the condition is true (in this case, if number is greater than 0), it executes the code inside the first set of curly braces {}. If the condition is false, it executes the code inside the second set of curly braces {}.

  5. printf("The number is positive.\n");: If number is greater than 0, this line prints "The number is positive." to the console.

  6. printf("The number is not positive.\n");: If number is not greater than 0, this line prints "The number is not positive." to the console.

  7. return 0;: Indicates the end of the main() function and returns 0, indicating successful program execution to the operating system.