编程知识 cdmana.com

Why not 123.456000 with float output

#include <stdio.h>
#include <stdlib.h>
int main()
{
float a=123.456;
printf("%f",a);
return 0;
}




Refer to the answer 1:

No extra at the end will be output 0, If the required output can be written as printf("%.6f",a);




Refer to the answer 2:

版权声明
本文为[CSDN Q & A]所创,转载请带上原文链接,感谢
https://cdmana.com/2021/12/202112121740428212.html

Tags float output
Scroll to Top