Download this source file
/* Temp.c - A program to convert between Fahrenheit and Celsius.
* This version correctly tests the return value of scanf.
* Written by Wayne Pollock, Tampa Florida USA
*/
#include
int main ( void )
{
float fahrenheit, celsius;
printf( "Please enter a temperature in degrees Fahrenheit: " );
if ( scanf( "%f", &fahrenheit ) != 1 )
return -1; /* indicates an error with scanf */
celsius = 5.0 / 9.0 * ( fahrenheit - 32.0 );
printf( "%.2f degrees Fahrenheit = %.2f degrees Celsius.\n",
fahrenheit, celsius );
return 0;
}