easy question

I want to do this calculation:

float interest;
float initBalance;

interest = (1/12) * (3/100) * initBalance;

cout << interest;

Problem is, (1/12) and (3/100) end up getting rounded to 0. What data type should I be using to prevent this?

Thanks.
(1.0f/12.0f) * (3.0f/100.0f)

The reason is that without a decimal point, C++ defaults to type 'int' and not to type 'float'. Putting the 'f' at the end indicates the numbers are to be treated as floats (without the 'f' but with the decimal point, they're treated as 'double's).
haha awesome thank you very much.
Topic archived. No new replies allowed.