fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. float x;
  5.  
  6. x = 12.34567; // x값에 저장
  7.  
  8. printf("%f\n", x); // 폭과 정밀도를 지정하지 않는 경우
  9. printf("%.2f\n", x); // 정밀도들 지정하는 경우 (소수점 이하 2자리)
  10. printf("%8.2f\n", x); // 폭과 정밀도를 지정하는 경우
  11.  
  12. return 0;
  13. }
  14.  
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout
12.345670
12.35
   12.35