Dividing fractions when reading from txt file.

Hi, my dad gave me an assignment where I've pretty much got everything down except
I have no idea how I would be able to do something like this:

10/5 = 2
10/3 = 3.33

If it divides evenly I have to make it without a double, if it doesn't divide evenly, I have to show 2 decimal points.

In my program I just made setf showpoint thing to 2 decimal places if it is division.

So, how would I solve this problem?
Thanks.
Nevermind, I just wasn't thinking :\

1
2
3
4
5
if (num1%num2 > 0){cout.setf(ios::fixed | ios::showpoint);
 cout.precision(2); 
 cout<<setw(3)<<num1<<" "<<setw(2)<<sign<<" "<<setw(3)<<num2<<" = "<<setw(8 <<result1<<endl;}
 else 
 cout<<setw(3)<<num1<<" "<<setw(2)<<sign<<" "<<setw(3)<<num2<<" = "<<setw(5)<<result1<<endl;}
Topic archived. No new replies allowed.