+ 1
Can we get fraction result in c++ ?
Example : 4/18 = 2/9 //in normal divison// But in c++, we get 0.22222 // in c++ //
1 Antwort
+ 1
First calculate the gcd for the numerator and the denominator then divide the numerator and the denominator by that value and you should have your result.
(if you have c++17)
https://en.cppreference.com/w/cpp/numeric/gcd