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:

1
2
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;
Thank you so much!! That did it. :D
Topic archived. No new replies allowed.