Problem! (Easy for most of you i'm sure)

Discussion in 'C++' started by Eurig Jones, Nov 6, 2003.

  1. Eurig Jones

    Eurig Jones Guest

    I'm a C++ newbie, just been starting out today... I really can't get my head
    around this...


    *****************

    int main()
    {
    int one = 1;
    int number = 43;

    double result = one / number;
    double result2 = static_cast<double>(one / number);

    cout << result << endl << result2;

    return 0;
    }

    *****************

    OUTPUT:

    0
    0

    *****************


    I dont understand!!! :-( please help

    thanks!
    Eurig Jones, Nov 6, 2003
    #1
    1. Advertising

  2. Eurig Jones

    lilburne Guest

    Eurig Jones wrote:
    >
    > *****************
    >
    > OUTPUT:
    >
    > 0
    > 0
    >
    > *****************
    >
    >
    > I dont understand!!! :-( please help
    >


    What is 1/43 when you can only have whole numbers?

    If you got this from a book see if it has an errata page.
    lilburne, Nov 6, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?dHJ1ZmF1eA==?=

    I'm sure this is easy

    =?Utf-8?B?dHJ1ZmF1eA==?=, Dec 13, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    333
    =?Utf-8?B?dHJ1ZmF1eA==?=
    Dec 13, 2005
  2. Richard
    Replies:
    15
    Views:
    3,676
    nice.guy.nige
    Feb 13, 2005
  3. Eurig Jones
    Replies:
    4
    Views:
    321
    John Brown
    Nov 6, 2003
  4. Todd_Calhoun
    Replies:
    3
    Views:
    351
    Todd_Calhoun
    Mar 25, 2005
  5. Replies:
    0
    Views:
    541
Loading...

Share This Page