0
How can I convert a float 2.3 to 2.300
or 1.54632 to 1.546
1 Resposta
+ 4
Use header file iomanip. And use function setprecision. Like this:
#include<iostream>
#include<iomanip>
using namespace std;
int main() 
{
		float a=2.3;
		float b=1.523469;
		cout<<fixed;
		cout<<setprecision(4)<<a<<endl;
		cout<<setprecision (3)<<b<<endl;
		return 0;
}





