allow decimals

• 10-28-2006
dankassdann
allow decimals
when I use "int" it doesnt allow decimals. What allows decimals?. Also lets say I make an integer called x, a and b, and I want x to be a*b what should I do?
• 10-28-2006
Daved
In C++ the default type for decimal numbers is double, so use double instead of int.

To assign the value of a*b to x, you do just that, assign a*b to x. If you know what the operator for assignment is in C++, that will help.
• 10-28-2006
Prelude
>when I use "int" it doesnt allow decimals.
That's because the int type stores an integer, which doesn't support precision. You want a real number, or floating-point, supported by the float, double, and long double types.

>Also lets say I make an integer called x, a and b, and I want x to be a*b what should I do?
First you should get a book on C++. Then you should read it.
• 10-28-2006
manutd
If you don't know a float or double in C++, you really need to take a course, look at this site's tutorials, or buy a book. And to answer your question about multiplying, use these lines of code:
Code:

```double a = 1.5; double b = 3.45; double x = a*b;```