Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program to compute the exact number of days between any two dates in his

ID: 3534928 • Letter: W

Question

Write a program to compute the exact number of days between any two dates in history. Call this program file b.c. A sample run, with user input in boldface, would be:

Note that the year must be entered as four digits since it can be from any century. (For this assignment you can ignore the fact that different calendars have been used in different periods in history, and just extend the calendar we currently use forward and backward in time.) The program should check the input format for each date, including: month between 1 and 12, and date within the actual number of days for that month. If an input error occurs the program should print an appropriate message and re-input the date. Use the following rule to compute leap years:

Any year which is a multiple of 4 is a leap year;
unless it’s also a multiple of 100, in which case it’s not a leap year; unless it’s also a multiple of 400, in which case it is a leap year. For example, 1800 is not a leap year, but 1600 is a leap year.

Explanation / Answer

please rate - thanks uploaded image #include #include #include int todoy(int,int,int); int leap(int); int validdate(int,int,int); void getDate(char[],int*,int*,int*); int main() {char date1[9],date2[9]; int month,day,year,days; int month2,day2,year2,doy,doy2,leapyear; int i,j; for(i=1;;) { printf("Enter first date: "); scanf("%s",&date1); getDate(date1,&month,&day,&year); printf("Enter second date: "); scanf("%s",&date2); getDate(date2,&month2,&day2,&year2); if(validdate(day,month,year)==0) printf("Invalid date "); else { if(validdate(day2,month2,year2)==0) printf("Invalid date "); else {if(year2doy2) printf("Invalid input "); else { days=0; if(year==year2) days=doy2-doy; else {for(j=year+1;j 30) return 0 ; else return 1; case 2 : if(leap(year)==1) max=29; if (day>max) return 0; return 1; } }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote