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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Eurig Jones

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

    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<dou ble>(one / number);

    cout << result << endl << result2;

    return 0;
    }

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

    OUTPUT:

    0
    0

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


    I dont understand!!! :-( please help

    thanks!





  • lilburne

    #2
    Re: Problem! (Easy for most of you i'm sure)

    Eurig Jones wrote:[color=blue]
    >
    > *************** **
    >
    > OUTPUT:
    >
    > 0
    > 0
    >
    > *************** **
    >
    >
    > I dont understand!!! :-( please help
    >[/color]

    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.

    Comment

    Working...