/* * FAHR1 -- program to print Fahrenheit temperatures between 0 and 300, * counting by 20s, and the corresponding centigrade temperaures * * Usage: fahr1 * * Inputs: none * Output: table of temperatures, as above * Exit Code: EXIT_SUCCESS (0) because all goes well * * written for ECS 030, Fall 2015 * * Matt Bishop, Sept. 24, 2015 * original program written */ #include #include /* * main routine * * print a table for Fahrenheit to Celsius * from 0 F to 300 F */ int main(void) { int fahr; /* fahrenheit temperature */ int celsius; /* celsius temperature */ register int lower = 0; /* begin table here */ register int upper = 300; /* end table here */ register int step = 20; /* increment */ /* * print out the lines for the table */ /* print the header */ printf("deg F\tdeg C\n"); /* print the values */ fahr = lower; while(fahr <= upper){ /* get corresponding temp in degrees C */ celsius = 5 * (fahr - 32) / 9; /* print it */ printf("%d\t%d\n", fahr, celsius); fahr += step; } /* * say goodbye */ exit(EXIT_SUCCESS); }