Loading
submit to reddit
May 25, 2013, 07:11:27 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome!
 
   Forum Home   Help Search Forum Login Register  
Pages: [1]   Go Down
  Send this topic  |  Print  
Author Topic: why c++ give different answer  (Read 1344 times)
sopian_87
Newbie
*
Posts: 2


« on: May 15, 2010, 05:23:51 PM »

when is calculate manually using calculator 365.25 x 2009 = 733787.25
but when in c++ the answer is 12891. why it be like tat and how i can get answer using c++ is 733787.25 .......pls help me  Smiley
Logged
Jenna Hall
Administrator
Full Member
*****
Posts: 152



WWW
« Reply #1 on: May 16, 2010, 08:45:34 PM »

Show us your code please that gave you the wrong answer in C++.
Logged
sopian_87
Newbie
*
Posts: 2


« Reply #2 on: May 17, 2010, 10:40:22 AM »

#include <math.h>
#include <iostream.h>   

   main()
    {
   
    int dd,mm,yyyy,mmN,yyyyN,B,A,C,D,Cc;
    char cal;
    const double pi = 3.1415926535897932384626433832795 ;
    double JD;

    cout << "\n Date of Observation [ddmmyyyy]:  ";
    cin  >>  dd >> mm >> yyyy;

    if ( dd >= 15 && mm >= 10 && yyyy >= 1582 ) goto cal;

            cal:
             if (mm <= 2)
               {
               yyyyN = yyyy - 1;
               mmN = mm + 12;

               cout << "\n\n yyyy'= " << yyyyN;
               cout << "\n\n mm'= " << mmN;

                                        A = yyyyN / 100;
               B = 2 - A + (A/4);
               cout << "\n A = " << A;
               cout << "\n B = " << B;
               C = 365.25 * yyyyN  ;
               cout << "\n C = " << C;
               D = 30.6001 * ( mmN + 1 );
               cout << "\n D = " << D;
               JD = B + C + D + dd + 1720994.5;
               cout << "\n JD = " << JD;
               }





    return 0;
    }
Logged
Haitam
Newbie
*
Posts: 16


« Reply #3 on: July 10, 2011, 04:12:16 AM »

you have to change the C and  D Parameters type you are using them as integers and integers can not contain Float numbers...
Logged
Pages: [1]   Go Up
  Send this topic  |  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!