Sunday, July 12, 2009

C programming?

I'm trying to make a program which will give the interest of a capital that is invested.


Can anyone tell me what type I have to use to define a result so it only shows 2 decimal points?


Thanks!

C programming?
You can use either float or double, but when printing the output, you must define the precision. For example,





printf("Interest: %9.2f\n", myInterest);
Reply:i say c++ is b eter and that you should jsut use that instead
Reply:If I remember correctly you can use either double or float. When you are printing you have to format output like this


printf("Interest is %2d dollars.",variable_interest);





This %2d will ensure that it shows only 2 decimal points.
Reply:currency. i'm not 100% positive. Let me know!
Reply:You should use the 'float' data type.


No comments:

Post a Comment