home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / alde_c / misc / func / math / c.lbr / FTOC.C < prev    next >
Encoding:
Text File  |  1988-07-21  |  640 b   |  23 lines

  1.  
  2.   /* print Fahrenheit-Celsius table
  3.         for f = 0, 20, ..., 300
  4.         (This program is from p. 8 of the Kernighan and Ritchie text)
  5.         */
  6. main()
  7. {
  8.     int lower, upper, step;
  9.     float fahr, celsius;
  10.  
  11.     lower = 0;         /* lower limit of temperature table */
  12.     upper = 300;       /* upper limit */
  13.     step = 20;         /* step size */
  14.  
  15.     fahr = lower;
  16.     while (fahr <= upper) {
  17.         celsius = (5.0/9.0) * (fahr-32.0);
  18.         printf("%4.0f %6.1f\n", fahr, celsius);
  19.         fahr = fahr + step;
  20.     }
  21. }
  22.  
  23.