menu search
person

Write a program in C++, to find if the given year is leap year or not using if else control structure.

thumb_up_alt 50 like thumb_down_alt 0 dislike
6 views

1 Answer

 
verified

#include <iostream>

using namespace std;


int main()

 {

    int year;


    cout << "Enter a year to check: ";

    cin >> year;


    if (year % 4 == 0) 

{

        if (year % 100 == 0) 

{

            if (year % 400 == 0)

                cout << year << " is a leap year.";

            else

                cout << year << " is not a leap year.";

        }

        else

            cout << year << " is a leap year.";

    }

    else

    cout << year << " is not a leap year.";

    return 0;

}



Output::
image


image

thumb_up_alt 50 like thumb_down_alt 0 dislike

Related questions

thumb_up_alt 50 like thumb_down_alt 0 dislike
6 views 1 answer
thumb_up_alt 50 like thumb_down_alt 0 dislike
5 views 1 answer
thumb_up_alt 50 like thumb_down_alt 0 dislike
3 views 1 answer
thumb_up_alt 50 like thumb_down_alt 0 dislike
2 views 1 answer
...