Hello, I need some help with a function in C. I just can\'t figure it out.I have
ID: 3618276 • Letter: H
Question
Hello,
I need some help with a function in C. I just can't figure it out.I have to write a function (call from function #2) that calculatesthe Calendar date given a Day-of-year and a year USING THEARRAY OF DAYS PER MONTH. YOU MUST traverse the ARRAY OFDAYS PER MONTH to find the correct month! The year will beused to determine if it's a leap year (call 5. below), so you'lladd 1 to the days for February if it is a leap year. Assignto "reference parameters" (pointer parameters in C) the month andday.
void calculateCalendarDate ( int daysOfMonth [],int dayOfYear, int *month, int *day, int year )
{
}
Thanks!
Explanation / Answer
please rate - thanks #include #include int leap(int); void fromdoy(int[],int,int,int*,int*); int main() {int doy,year,error=0,day,month; int daysinmonth[12]={31,28,31,30,31,30,31,31,30,31,30,31}; printf("Enter year: "); scanf("%d",&year); do {error=0; printf("Enter day of year: "); scanf("%d",&doy); if(doy>365) {if(doy==366) {if(leap(year)==0) error=1; } else error=1; } if(error==1) printf("Invalid day of year "); }while(error==1); fromdoy(daysinmonth,doy,year,&day,&month); printf("In %d day %d is %d/%d ",year,doy,month,day); getch(); return 0; } void fromdoy(int inmonth[],int doy,int year,int* day, int*month) //change date to day ofyear {int daysinmonth; inti; for (i=1;iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.