Can't get output to product decimal

I am trying to calculate the quotient of two numbers. However, when they do not divide evenly, I want it to product a decimal instead of just the integer. I have only been using cpp for a week now so simple solutions would be appreciated! I know it has to do with double or float I am just a bit lost.

1
2
3
4
5
6
int quotient;
	if (integerOne > integerTwo)
		quotient = (integerOne / integerTwo);
		else if (integerOne < integerTwo)
			quotient = (integerTwo / integerOne);
				else quotient = (integerOne / integerTwo);
You need to use a data type of float or double
Not an int data type.
@fiji885 what do I change to float? quotient?
1
2
double quotient = integerOne >= integerTwo ? 
    double(integerOne)/integerTwo : double(integerTwo)/integerOne;


One of integerOne or integerTwo must be interpreted as a float or double value for the division to produce a non-integer value, and then you need a non-integer variable to store it in.
Topic archived. No new replies allowed.