# Counting Number of days from year zero

• 06-15-2002
wireless
Counting Number of days from year zero
I have to write this function

int totDay(int m, int d, int y);
The function returns the total number of days for the given month, day and year from date zero. The teacher gave us a hint (initialize the total to the number of julian days in given year, then add to the total number of days in each year preceding the given year.)

This is my julian day function, it works.
Code:

```int julianDay(int month, int day, int year) { if (theMonth == 1) theJulian = theDay; if (theMonth == 2) theJulian = theDay + 31; if (theMonth == 3) theJulian = theDay + 31 + 28; if (theMonth == 4) theJulian = theDay + 31 + 28 + 31; if (theMonth == 5) theJulian = theDay + 31 + 28 + 31 + 30; if (theMonth == 6) theJulian = theDay + 31 + 28 + 31 + 30 + 31; if (theMonth == 7) theJulian = theDay + 31 + 28 + 31 + 30 + 31 + 30; if (theMonth == 8) theJulian = theDay + 31 + 28 + 31 + 30 + 31 + 30 + 31; if (theMonth == 9) theJulian = theDay + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 1; if (theMonth == 10) theJulian = theDay + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30; if (theMonth == 11) theJulian = theDay + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31; if (theMonth == 12) theJulian = theDay + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30; return theJulian; }```
what i dont understand to do is the part where it says
add to total the number of days in each year preceding the given year

Any ideas?
• 06-15-2002
blight2c
does the teacher mean to add all the days of the preceding year to the number of days in the current year? in other words, a recursive function adding the days from present to 0 ce?
• 06-15-2002
Unregistered
year has 365 days if it is not leap(?) year then it has 366 days.
so if the year is 0003 then it would be 365+365+365.

Check the formula for years in net.

Does the julian calender has days that not exits or was those
only in earlier calenders. Check that also.

;jackz
• 06-15-2002
wireless
What if I have a year like 1992 or 2006?
• 06-16-2002
Unregistered