Error(s) found: '1'

  • Unable to perform the query 'UPDATE cpp_code SET clickthru=clickthru+1 WHERE fid=33'. Table 'cpp_code' is read only.

  • C++ MADE EASY
    Code About Us Tutorial




       
     

    Home > myCode > Calculates the No. of days since 2000 Millenium

    November 30, 2009 9:30 pm

       

    Calculates the No. of days since 2000 Millenium


    Posted on: 2003-05-19 07:34:41
    Number of times viewed: 179

     
     
    // 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 ();
          }

    Please Rate this Code:



     «12039» THINKQUEST TEAM C0111571 © 2001. All Rights Reserved.