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

Write a function day_of_year(month, day, year) that returns the day of the year

ID: 3641698 • Letter: W

Question

Write a function day_of_year(month, day, year) that returns the day of the year (an integer between 1 and 366) specified by the three augments.

Explanation / Answer

int day_of_year(int year, int month, int day) { int i, leap; if (year < 1752 || month < 1 || month > 12 || day < 1) return -1; leap = (year%4 == 0 && year%100 != 0) || year%400 == 0; if (day > daytab[leap][month]) return -1; for (i = 1; i 366) || (!leap && yearday > 365)) return -1; for (i = 1; yearday > daytab[leap][i]; i++) yearday -= daytab[leap][i]; *pmonth = i; *pday = yearday; return 0; } /* main: test day_of_year and month_day */ int main(void) { int year, month, day, yearday; for (year = 1970; year
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