Write a function that is passed two date structures, d1 and d2, and returns an i
ID: 1798528 • Letter: W
Question
Write a function that is passed two date structures, d1 and d2, and returns an integer. Your function will compare the two dates and return -1 if d1 is earlier than d2, 1 if d1 is later than d2, and 0 if d1 and d2 are the sameExplanation / Answer
struct date { int day; int month; int year; }; int function( **date1,**date2){ int out=0; if (date1->year > date2->year) out=1 else if (date1->year year) out=-1; endif; endif; if (out==0) { if (date1->month > date2->month) out=1 else if (date1->month month) out=-1; endif; endif; } endif if (out==0) { if (date1->day > date2->day) out=1 else if (date1->day day) out=-1; endif; endif; } endif; return out; }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.