/* * FAHR2 -- program to print Fahrenheit temperatures between 0 and 300, * counting by 20s, and the corresponding centigrade temperaures * It uses floating point numbers and a different control structure * than fahr1.c * * Usage: fahr2 * * Inputs: none * Output: table of temperatures, as above * Exit Code: 0 because all goes well * * Matt Bishop, Sept. 29, 2019 * original program written */ #include /* * macros for constants */ #define LOWER 0 /* begin table here */ #define UPPER 300 /* end table here */ #define STEP 20 /* increment */ /* * print a table for Fahrenheit to Celsius * from 0 F to 300 F * floating point version */ int main(void) { float fahr; /* fahrenheit temperature */ /* * print out the lines for the table */ /* print the header */ printf("deg F\t deg C\n"); /* print the values */ for(fahr = LOWER; fahr <= UPPER; fahr += STEP) printf("%3.0f\t%6.1f\n", fahr, (5.0/9.0) * (fahr - 32)); /* * say goodbye */ return(0); }