What data type do I use for decimals?

1
2
average = sum / 2;
cout << "Average is: " << average << endl;


For example, if I put the sum of 3 and 2 and its 5. The average answer will be 2... I want it to be 2.5!! How do I do this lol?
Last edited on
Ever heard of type float?
Make sure one of the sides of the division is a floating point (float or double) and you will do that kind of division.

For example:
average = sum / 2.0

Now 2 is a double so you will do double division, resulting in a double result.
I'm a noob.... derp
Topic archived. No new replies allowed.