Cpp program to check leap year

 What is a leap year

The year which contains one day extra for the synchronization of the calendar year with the astronomical year. The year divisible by 4 and divisible by 100 is not but divisible by 400 is known as a leap year.

For understanding the following code you must learn first if-else.

Code:

#include <iostream>

using namespace std;


int main()

{

    int years;


    cout << "Enter a year: ";

    cin >> years;


    if (years % 4 == 0)

    {

        if (years % 100 == 0)

        {

              if (years % 400 == 0)

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

         else

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

                

            

        }

        else

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

    }

    else

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


    return 0;

}

Output

Enter a year: 1700

1700 is not a leap year.



Comments

Popular posts from this blog

Diferrence between flutter and react native

Flutter Widgets

Flutter layout