Explanation: Standard I/O library is included.
As an input from the user, we declare a variable year.
The user is prompted to input and view a year.
To determine if a year qualifies as a leap year, we look for divisibility by 4 rather than 100 unless it is also divisible by 400.
The checks determine whether or not the year is a leap year.

#include <stdio.h>

int main() {
    int year;
    printf("Enter a year: ");
    scanf("%d", &year);

    // Check leap year conditions
    if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
        printf("%d is a Leap Year.\n", year); // Output if it's a leap year.
    } else {
        printf("%d is not a Leap Year.\n", year); // Output if it's not a leap year.
    }
    return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Verified by MonsterInsights