Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   C++ (https://www.askmehelpdesk.com/forumdisplay.php?f=439)
-   -   Programming a decimal in c ++! (https://www.askmehelpdesk.com/showthread.php?t=258640)

  • Sep 9, 2008, 05:12 PM
    kelsjane24
    Programming a decimal in c ++!
    Ok I am writing a program that asks the user to insert two numbers and the program then divides the numbers they choose. However, when the program divides these numbers it shows 2.00 when really it should be 2.44. How do I make the program show what the answer really is. Please Help! Thanks!!
  • Sep 11, 2008, 07:38 PM
    Scleros
    Hint: check your variable type declarations.
  • Oct 15, 2008, 12:32 PM
    mani_jeddah

    Simply use the data type "float or double" but don't use int!

    Vote for my ans if it is useful
  • May 20, 2009, 07:00 AM
    Libran

    One way is simply use float or double instead of int.
    Or make use of type casting feature (explicit typecasting)
    Cout<<float (a/b);

  • All times are GMT -7. The time now is 07:33 PM.