Adding decimal digitals to whole number doubles
Right now I am doing some C++ challengers (beginner) that I found on another site.
I've completed it, but I dont like the output.
Let's take this code for example:
double mynum = 10;
cout << mynum;
Despite the number being a double, the output is still
My question, how do I force the output to consist of a decimal number, i.e.
I have tried setpricision(4) however that only works if there is already a decimal place. I have also tried Googling and turned out nothing.
double x = 10.0;
std::cout << std::fixed << std::setprecision( 4 ) << x << std::endl;
Thank you so much!! That did it. :D
Topic archived. No new replies allowed.