/* June 4, 1998 */ /* program to convert temperature to fahrenhiet or celsius */ #include main () { /* declaration */ char temp_type; float temp, fahren, celsius; /* user's input */ printf("Enter the temperature to be converted: "); scanf("%f", &temp); /* select c or f for celsius and fahrenhiet respectively */ printf("Enter an f if the temperature is in Fahrenhiet"); printf("\n or a c if the temperature is in Celsius: "); scanf("\n%c",&temp_type); /* if statement to determine type of conversion */ if (temp_type == 'f' || temp_type =='F') { celsius = (5.0 / 9.0) * (temp - 32.0); printf("\nThe equivalent Celsius temperature is %6.2f \n", celsius); } else { fahren = (9.0 / 5.0) * temp + 32.0; printf("\nThe equivalent Fahrenheit temperature is %6.2f \n", fahren); } }