float y= 0.5;
cout<<y; //will give output 0.5
//i want output as 0.50
//what to do?
you can use cout<<setprecision(n)<<y which will set the precision up to n decimals.
1 Like
Don’t forget the fixed part (fixed floating-point notation)
cout << fixed << setprecision(n) << y;