Help in setting the number of zeroes in a double data type

Hi just wanted to know how to set the number of zeroes after the decimal for the double data type.
for example
double z=3;
gives no zeroes after decimal.

Thanks in advance

Setprecision when used along with ‘fixed’ provides precision to floating point numbers correct to decimal numbers mentioned in the brackets of the setprecison.

Try giving output like this:

1 Like

@cherry0697 thanks, buddy…

Can also use printf("%.3f",z) to print correct to 3 decimal places. If z is 23.34 it prints 23.340

@bal_95 …hmm I knew that I was looking for some clarity for the setprecision( ) function … But thanks anyways … :+1: :+1: