A year in the modern Gregorian calendar normally consists of…
A year in the modern Gregorian calendar normally consists of 365 days. However, the Earth takes slightly longer than 365 days to complete one orbit around the Sun. To account for this difference, a leap year occurs every few years, adding an extra day to the calendar. A leap year contains 366 days, with February 29th as the additional day. Write a C++ program that accepts a year as input and determines whether it is a leap year based on the following rules: The year must be evenly divisible by 4. If the year is a century year (for example, 1700, 1800, 1900, etc.), it must also be evenly divisible by 400 to be considered a leap year. For example, 1700 and 1800 are not leap years because they are not divisible by 400. The year 2000 is a leap year because it is divisible by 400. Your program should display the year followed by the appropriate message: ” – leap year” if the given year is a leap year. ” – not a leap year” if the given year is not a leap year. Example 1: Input: 1712 Output: 1712 – leap year Input: 1913 Output: 1913 – not a leap year
Read Details