#include int main () { double a = 1234.56789; double b = 299792458; double c = 6.62607e-34; /* Default printing. */ printf ("Using %%f (fixed point): %f %f %f.\n", a, b, c); printf ("Using %%e (force exponent): %e %e %e.\n", a, b, c); printf ("Using %%g (best fit): %g %g %g.\n", a, b, c); /* With a width. */ printf ("Using %%15f: %15f %15f %15f.\n", a, b, c); printf ("Using %%15e: %15e %15e %15e.\n", a, b, c); printf ("Using %%15g: %15g %15g %15g.\n", a, b, c); /* With a width and precision. */ /* This forces three decimal places. */ printf ("Using %%15.3f: %15.3f %15.3f %15.3f.\n", a, b, c); /* This forces three decimal places of mantissa. */ printf ("Using %%15.3e: %15.3e %15.3e %15.3e.\n", a, b, c); /* This forces two decimal places of mantissa. */ printf ("Using %%15.3g: %15.3g %15.3g %15.3g.\n", a, b, c); /* Let's go crazy. */ printf ("Using %%15.10f: %15.10f %15.10f %15.10f.\n", a, b, c); printf ("Using %%15.10e: %15.10e %15.10e %15.10e.\n", a, b, c); /* %g doesn't print trailing zeroes. */ printf ("Using %%15.10g: %15.10g %15.10g %15.10g.\n", a, b, c); return 0; }