Question: Copy your temperature.c file from your Lab3 directory into your Lab4 directory. Modify the program to compute the conversion from Fahrenheit to Celsius in a

Copy your temperature.c file from your Lab3 directory into your Lab4 directory. Modify the program to compute the conversion from Fahrenheit to Celsius in a function called tocelsius(). The prototype for this function is:

float tocelsius(float fahrenheit);

/* Given: a temperature reading in degrees Fahrenheit

Returns: the temperature in degrees Celsius

*/

Modify the driver, main(), to prompt the user to enter a temperature in Fahrenheit, convert the value using the function and print the result. The driver should loop asking the user for input until a special data value is entered. Since 0 is a valid Fahrenheit temperature, we need something else. Physics tells us that no temperature can be lower than absolute zero (-273 degrees C, or -459 degrees F), let's use -500 as the special data value to terminate Fahrenheit input. Your file will be called temperature.c.

Here is the original file temperature.c file

Copy your temperature.c file from your Lab3 directory into your Lab4 directory.

#include int main() float fahrenheit; float celsius printf("Enter the temperature in fahrenheit: 'scanf("%f", &fahrenheit) /* Convert the temperature from fahrenheit to celsius */ celsius = (fahrenheit - 32) * 5/9 printf(" %.2f Fahrenheit = %.2f_Celsius ", fahrenheit, celsius) return of

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!