Printing fractions in C++ | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

Printing fractions in C++

I was wondering how I could print a fraction in C++ on SoloLearn without the compiler doing the math before printing it. When I write in fraction format (lets say 1/2 and 3/8), the compiler does the math and prints the quotient (0.5 and 0.375, respectively). I want to be able to print the fraction, not the quotient of the division problem. Is there any way I could do that on SoloLearn?

31st Jul 2020, 10:12 PM
UnEpic_NotDeveloper
1 Respuesta
+ 1
The only way to do it (that I know of) is to print it out as a string.
31st Jul 2020, 11:34 PM
Samuel Adepoju
Samuel Adepoju - avatar