How to output fraction instead of decimal number?

You can’t. You would need to write a class dedicated to holding rational numbers (i.e. fractions). Or maybe just use the Boost Rational Number library.

Leave a Comment