hello
this is niharika
i need help with an assignment.
the question is
Implement a function that converts a day of the year (a number between 1 and 366) into a month and day.
int dateSplit(int dayOfYear, int year, int *day, int *month);
The function should return 1 if the conversion is sucessful and 0 if dayOfYear and/or year are not valid.
A sample program testing the function, along with its output, is given below.
Your test program and your solution should be placed in separate files. Submit only the file dateSplit.c containing your solution function.
Code:
Sample Test Program
#include <stdio.h>
int dateSplit(int dayOfYear, int year, int *day, int *month);
void testDateSplit(int dayOfYear, int year)
{
int day, month;
if (dateSplit (dayOfYear, year, &day, &month))
printf ("%d,%d => %d,%d\n", dayOfYear, year, day, month);
else
printf ("%d,%d => invalid\n", dayOfYear, year);
}
int main (void)
{
testDateSplit (100, 2007);
testDateSplit (100, 2008);
testDateSplit (1, 2007);
testDateSplit (1, 2008);
testDateSplit (365, 2007);
testDateSplit (366, 2007);
testDateSplit (366, 2008);
testDateSplit (-1, -1);
return 0;
}
Sample Output
100,2007 => 10,4
100,2008 => 9,4
1,2007 => 1,1
1,2008 => 1,1
365,2007 => 31,12
366,2007 => invalid
366,2008 => 31,12
-1,-1 => invalid
here i need to write the main funtion for this program statement as the test program is already given. please help me. i nee the code. it is urgent