Use printf to control the output format : Formatted Output Float « Console « C / ANSI-C






Use printf to control the output format


#include <stdio.h>

int main(void)
{
  double item;

  item = 10.12304;

  printf("%f\n", item);
  printf("%10f\n", item);
  printf("%012f\n", item);

  return 0;
}


  

           
       








Related examples in the same category

1.Outputting floating-point valuesOutputting floating-point values
2.Output float with format: round
3.Printf with format
4.More output format with printf