/* * temperature_conversion.c * * K&R Exercise 1.4 * Print Celsius-Fahrenheit table * for celsius = -100, -90, ... 0, 10, ... 100. * */ #include #define LOWER -100 #define UPPER 100 #define STEP 10 int main() { float celsius, fahr; celsius = LOWER; while (celsius <= UPPER) { fahr = 9.0/5.0 * celsius + 32.0; /* * printf modifiers: * %f floats * %d ints * * special characters: * \n newline * \t tab * * width.precision for %f */ printf("Celsius: %6.1f\t Fahrenheit: %6.1f\n", celsius, fahr); celsius = celsius + STEP; } return 0; }