English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

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!

2007-02-03 04:59:20 · 5 answers · asked by Huwbutts 2 in Computers & Internet Programming & Design

5 answers

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);

2007-02-03 06:11:22 · answer #1 · answered by BigRez 6 · 1 0

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.

2007-02-03 05:14:32 · answer #2 · answered by gljivarm 2 · 3 0

You should use the 'float' data type.

2007-02-03 07:16:52 · answer #3 · answered by Big C 1 · 0 0

currency. i'm not 100% positive. Let me know!

2007-02-03 05:11:55 · answer #4 · answered by B0NER 3 · 0 2

i say c++ is b eter and that you should jsut use that instead

2007-02-03 05:56:13 · answer #5 · answered by patdog 3 · 0 3

fedest.com, questions and answers