Ask Experts Questions for FREE Help !
Ask
    kelsjane24's Avatar
    kelsjane24 Posts: 1, Reputation: 1
    New Member
     
    #1

    Sep 9, 2008, 05:12 PM
    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!!
    Scleros's Avatar
    Scleros Posts: 2,165, Reputation: 262
    Hardware Expert
     
    #2

    Sep 11, 2008, 07:38 PM
    Hint: check your variable type declarations.
    mani_jeddah's Avatar
    mani_jeddah Posts: 75, Reputation: -1
    Junior Member
     
    #3

    Oct 15, 2008, 12:32 PM

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

    Vote for my ans if it is useful
    Libran's Avatar
    Libran Posts: 43, Reputation: 0
    Junior Member
     
    #4

    May 20, 2009, 07:00 AM

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

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Calculating pi to n decimal places [ 5 Answers ]

Suppose your goal is to calculate (not look up) a value of pi that is accurate to n decimal places. Suppose n were 10. How would you do it?

Pi by recursive decimal places [ 5 Answers ]

I would like to know if there is a way to calculate pi by using the current last decimal place to calculate the next decimal place. I already made a formula for pi that I posted on another board, but someone suggested I copy here. ---Begin quote--- This doesn't really fit anywhere so I'm just...

Decimal placements [ 2 Answers ]

Write down the decimal fraction equivalent to fourteen and twenty-five hundredths

Decimal [ 24 Answers ]

I need help on my h.w it say write a decimal for fraction or mixed number questiom #1 3 - = what is the answer 10

Decimal placement [ 2 Answers ]

.40% .10% With the decimel point in front of the number, and without any zeros. I know .40% must be a small percent of a 100. I know its not 40% or 4% Same with .10%


View more questions Search