FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 59   



Following program shows you how take a year as input and tells whether it's a leap year or not.

#include <stdio.h>
int main() {
    int input;

    printf("Enter a year:");
    scanf("%d", &input);

    if (input % 4 == 0) {
        if (input % 100 == 0) {
            if (input % 400 == 0) {
                printf("%d its a leap year", input);

            } else {
                printf("%d its not a leap year", input);
            }

        } else {
            printf("%d its a leap year", input);
        }
    } else {
        printf("%d its not a leap year", input);
    }
}

Output:

Example1:

Enter a year: 2012
2012 its a leap year

Example2:

Enter a year: 2019
2019 its not a leap year



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News