/* Program: prfloat.c Testing the printf function. */ #include #include "genlib.h" #include "simpio.h" main() { double x ; x = 3.14159 ; printf("1234567890123456789012345\n") ; printf("%f\n",x) ; printf("%4.2f\n",x) ; printf("%8.2f\n",x) ; printf("%-8.2f%-8.2f%-8.2f\n", x, x, x) ; printf("%e\n", x) ; x = x / 100000.0 ; printf("%g %.3g\n",x,x) ; } ------------------------------------ 1234567890123456789012345 3.141590 3.14 3.14 3.14 3.14 3.14 3.141590e+00 3.14159e-05 3.14e-05