set precision in c++

C++
float x;
cout<<fixed<<showpoint;
cout<<setprecision(2) << x;printf("%0.4f", num);
Source

Also in C++: