home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / qc_prog / chap03 / specs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-04-06  |  649 b   |  19 lines

  1. /* specs.c -- shows printf() format  */
  2. /*            specifiers for numbers */
  3.  
  4. main()
  5. {
  6.     int    i = 122;       /* ASCII code for 'z' */
  7.     long   l = 93000000;  /* distance to Sun (miles) */
  8.     float  f = 192450.88; /* someone's bottom line */
  9.     double d = 2.0e+030;  /* mass of Sun (kg.) */
  10.  
  11.     printf("%d\n", i);  /* integer as decimal */
  12.     printf("%x\n", i);  /* integer as hex */
  13.     printf("%ld\n", l); /* long */
  14.     printf("%f\n", f);  /* float as decimal */
  15.     printf("%e\n", f);  /* float as exponential */
  16.     printf("%f\n", d);  /* double as decimal */
  17.     printf("%d\n", d);  /* double as exponential */
  18. }
  19.