| |
// author: christos L.
#include <iostream.h>
#include <conio.h>
void main ()
{
int dayNumber, day, month, year ;
cout << "This program calculates the number of days since 1st January 2000 at 00:00
universal time: " << endl ;
cout << "Enter the day in (dd): " ;
cin >> day ;
cout << "Enter the month in (mm): " ;
cin >> month ;
cout << "Enter the year in (yyyy): " ;
cin >> year ;
dayNumber = 367*year - (7*(year + ((month+9)/12)))/4 + (275*month)/9 + day -730531 ;
/* i have correct the above formula from -730530 to -730531
because if you , i.e. enter 03/01/2000 it returns 3 days.
I think that it should be, in fact 2 days since 1st January.
I checked the corrected formula with an on-line calculator and both
returned the same number of days for 06/05/2003. I think that the formula
in the handout regards the 1st of January as zero date */
cout << "dayNumber : " << dayNumber ;
getche ();
} |