20.09.2015 Views

Programming in C

Kochan - ProgramminginC

Kochan - ProgramminginC

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

192 Chapter 9 Work<strong>in</strong>g with Structures<br />

days between July 2, 2005, and July 16, 2005, is obviously 14. But how many days<br />

are there between August 8, 2004, and February 22, 2005? This calculation requires<br />

a bit more thought.<br />

Luckily, a formula can be used to calculate the number of days between two dates.<br />

This is affected by comput<strong>in</strong>g the value of N for each of the two dates and then<br />

tak<strong>in</strong>g the difference, where N is calculated as follows:<br />

N = 1461 x f(year, month) / 4 + 153 x g(month) / 5 + day<br />

where<br />

f(year, month) = year - 1 if month

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!