home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / PERI_50.ZIP / PERI.PGM / FTOC.C < prev    next >
Encoding:
Text File  |  1990-08-20  |  505 b   |  21 lines

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