/* ****** BUGGY VERSION ***** * * 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: EXIT_SUCCESS (0) because all goes well * * Matt Bishop, Oct. 1, 2019 * original program written */ #include #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/9) * (fahr - 32)); /* * say goodbye */ return(EXIT_SUCCESS); }