For printf (again from Harbison and Steele):
%f or %lf prints a float or a double (use %Lf for long double) to a minimum precision
%e or %le (respectively %Le) prints in scientific notation, again to a minimum precision
%g or %lg (respectively %Lg) decides whether %f or %e fits the situation better, uses that, but then strips off trailing zeros
%e %g use a lower case 'e' before the exponent, %E %G use upper case (%F is not a standard code).
%a (%la %La %A etc) is a C99 addition for printing in hexadecimal floating point, but doesn't seem to be implemented in the libc I'm using (cygwin's).
Try this:
#include <stdio.h>
int main(void)
{
double mydouble;
printf("Enter a number\n");
scanf("%lg",&mydouble);
printf("you typed (%%f) %f\n", mydouble);
printf("you typed (%%g) %g\n", mydouble);
printf("you typed (%%e) %e\n", mydouble);
return 0;
}
For more details on setting the precision and other formatting gewgaws, check out the http://www.gnu.org/software/libc/manual/html_node/Floating-Point-Conversions.html#Floating-Point%20Conversions page for glibc.