FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 81   



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

#include <iostream>

int main() {
    int input;
    std::cout << "Enter a year:";
    std::cin >> input;
    if (input % 4 == 0) {
        if (input % 100 == 0) {
            if (input % 400 == 0) {
                std::cout << input << " its a leap year";

            } else {
                std::cout << input << " its not a leap year";
            }

        } else {
            std::cout << input << " its a leap year";
        }
    } else {
        std::cout << input << " its not a leap year";
    }
}

Output:

Example1:

Enter a year: 2003
2003 its not a leap year

Example2:

Enter a year: 1880
1880 its a leap year



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News