How do i get the fraction for any decimal number in a variable?
Code:Code:#include<iostream> using namespace std; int main() { double x = 1/6; cout << x; cin.get(); }
How do i get the fraction for any decimal number in a variable?
Code:Code:#include<iostream> using namespace std; int main() { double x = 1/6; cout << x; cin.get(); }
with floating point division.
double x = 1.0 / 6.0;