Adding decimal digitals to whole number doubles

closed account (NyhkoG1T)
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 still10

My question, how do I force the output to consist of a decimal number, i.e. 10.00000

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;
closed account (NyhkoG1T)
Thank you so much!! That did it. :D
Topic archived. No new replies allowed.