Question: WT years that are evenly divisible by 400 or are evenly divisible by 4 and not evenly divisible by 100 are leap years. For example,

 WT years that are evenly divisible by 400 or are evenly

WT years that are evenly divisible by 400 or are evenly divisible by 4 and not evenly divisible by 100 are leap years. For example, since 1600 is evenly divisible by 400, the year 1600 was a leap year. Similarly, since 1988 is evenly divisible by 4 but not by 100, the year 1988 was also a leap year. Using this information, write a function leap that gets a year as a parameter, and returns 1 if that year is a leap year, o if it is not Write a function numOfDays that takes three integers as parameters, representing the day, month and year of a date, and calculates total number of days that have passed from the beginning of the given year. For this calculation use an array whose elements are initialized (during decleration) to the number of days of each month as follows: 31 31 31 30 31 31 30 31 30 31 (standing for Jan Feb Mar Apr May Jun July Aug Sep Oct Nov Dec) 28 30 Do not forget to check whether the year is leap or not. For example, if the date is 3 4 2000, the function should return 94 (31 +29+31 +3) Write a function check_date that checks whether a given date is valid or not, using an array as the one in second part. Write a program that will ask for two dates, as day, month and year (eg; 9 3 2001 represents 9th of March in 2001), validates the dates using the function check_date and displays the number of days between them, using the function numOfDays. Your program should also validate that both dates are within the same year. Do not forget to check whether the year is leap or not. Example Run#1 : Enter the first date: 29 2 2010 Invalid date! Enter the first date again: 29 2 2008 Enter the second date: 30 9 2008 The difference between two dates is 214 days. Example Run#2: Enter the first date: 1 13 2011 Invalid date! Enter the first date again: 1 1 2011 Enter the second date: 29 2 2012 Invalid date! Enter the second date again: 29 2 2011 Invalid date! Enter the second date again: 28 2 2011 The difference between two dates is 58 days. Example Run#3: Enter the first date: 1 5 2011 Enter the second date: 31 4 2011 Invalid date! Enter the second date again: 30 4 2011 The difference between two dates is 1 days

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!