Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Math C++

Status
Not open for further replies.

RollerMan

Technical User
Jan 27, 2002
6
US
Anyone familar with mixed fractions?

I understand how to reduce them to lowest terms but now I am trying to figure out how to convert it to a mixed number.

example:

25/6= 4-1/6

any clues?

 
cout << int(a/b) << &quot;-&quot; << a%b << &quot;/&quot; << b <<endl;

Of course, that's going to look a bit silly if a%b is 0. Perhaps something along the lines of:

cout << int(a/b);
if (a%b)
{
cout << &quot;-&quot; << a%b << &quot;/&quot; << b;
}
cout << endl;

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top