A leap year (also known as an intercalary year or bissextile year) is a calendar year that contains an additional day (or, in the case of a lunisolar calendar, a month) added to keep the calendar year synchronized with the astronomical year or seasonal year.[1] Because astronomical events and seasons do not repeat in a whole number of days, calendars that have the same number of days in each year drift over time with respect to the event that the year is supposed to track. By inserting (called intercalating in technical terminology) an additional day or month into the year, the drift can be corrected. A year that is not a leap year is a common year.
Source Code:
A leap year is a year in which an extra day is added to the calendar in order to synchronize it with the seasons. Since the tropical year is 365.242190 days long, a leap year must be added roughly once every four years (four times the fractional day gives ). In a leap year, the extra day (known as a leap day) is added at the end of February, giving it 29 instead of the usual 28 days.
Source Code:
#include <iostream>
using namespace std;
int main()
{
int year;
cout << "Enter a year: ";
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;
}
Post a Comment