C Question regarding decimal(floating point ) number

How can i make sure a definite number of digit after the decimal point

if you are using using cout and say your variable is x which contains this floating point number then use cout<<fixed<<showpoint<<setprecision(a)<<x ;

Here a is the number of digits after the decimal point you wish to add. Also you have to add the header file #include

Using printf say u want a characters in decimal then u can write it as printf("%.af", x); in ur case it shud be printf("%.2f", x); and suppose its a long double variable then, ("%.2lf", x)

1 Like

bt if i m using printf() and scanf()…say in a certain result in which i want two numbers after decimal like…(54.09,78.03,45.27)