/* Program to convert Fahrenheit degrees to Celsius. Requests values until -999 entered. */ #include #include main () { float F, C; /* Fahrenheit & Celsius */ printf("Enter Fahrenheit (-999 to stop): "); scanf("%f", &F); /* Note: the following line compares the float F with -999. This is OK, but floats should not be compared for exact (in)equality with fractional or very large numbers, because of rounding errors - see text chapter 16. */ while (F != -999) { C = 5. * (F - 32.) / 9.; printf( " Celsius is %.0f\nEnter Fahrenheit (-999 to stop): ", C ); scanf("%f", &F); } }