Question
Question: Modify the driver, main(), to prompt the user to enter a temperature in Fahrenheit, convert the value using the function and print the result.
Question:
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.
This is what i have right now, and I dont know how I should end this while loop. When I run the program, it just keep printing the degree in celsius and never stop in the background. Thanks in advance!!!
float tocelsius(float fahrenheit);
int main()
{
float celsius;
float fahrenheit;
float degree = 1;
/* this is a while loop and it will continue until some specific value is entered.
*/
while (degree ==1)
{
printf("Enter the degree in Fahrenheit: " );
scanf("%.2f,&fahrenheit");
/* convert fehrenheit to celsius */
celsius = tocelsius(fahrenheit);
/* print the result */
printf("the degree in celsius is %.2f ",celsius);
printf("Please enter the degree in Fahrenheit again: ");
scanf("%.2f,&fahrenheit");
}
/* compute the degree in Fahrenheit */
printf("enter the degree in Fahrenheit: ");
scanf("%f",&fahrenheit);
/* convert fehrenheit to celsius */
celsius = (fahrenheit - 32) * 5/9;
/* print the result */
printf("the degree in celsius is %.2f ", celsius);
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started