Lets consider we have a double R = 99.999999; (which may be obtained by a result of some other computation),now the desired output is 99.99
double R = 99.999999;
I tried using printf("%.2lf",R); but it's rounding off the value.How to get the desired output ? (preferably using printf)
printf("%.2lf",R);
printf
sprintf it into a buffer, and then put the NUL char two bytes past the '.'
sprintf
Then printf your final string using the intermediate one.