Answer :
Here's the complete question:
Write a program in C that gives user menu to choose from –
1. Convert temperature input from the user in degrees Fahrenheit to degrees Celsius
2. Convert temperature input from the user in degrees Celsius to degrees Fahrenheit
3. Quit.
Formulae- C = (5 / 9) * (F-32) and F = (9/5) * C + 32
#include
#include
/*
A C program that gives user menu to choose from –
1. Convert temperature input from the user in degrees Fahrenheit to degrees Celsius
2. Convert temperature input from the user in degrees Celsius to degrees Fahrenheit
3. Quit.
Formulae- C = (5 / 9) * (F-32) and F = (9/5) * C + 32
*/
//create menu
//input
//process
//output
//function1 C= (fahrenheit-32) * 5/9;
int function1(int input) {
int result;
result = ((double) 5/9) * (input-32);
return result;
}
//function2 F = (°C * 9) / 5 + 32
int function2(int input) {
int result;
result = ((input * 9)/5) + 32;
return result;
}
int main() {
//declare variables
int choice = 0;
int fah = 0, cel = 0;
double newCel = 0, newFah = 0;
do {
//output menu to screen
printf("Choose an option \n");
printf("1. F-> C \n");
printf("2. C -> F \n");
printf("3. Exit \n");
scanf("%i", &choice);
printf("You entered %i \n", choice);
//take action based on choice
switch(choice) {
case 1:
printf("Enter the temperature in degrees fahrenheit: \n");
scanf("%d", &fah);
newCel = function1(fah);
printf ("The converted temperature is %.2lf\n", newCel);
break;
case 2:
printf("Enter the temperature in degrees celsius: \n");
scanf("%d", &cel);
newFah = function2(cel);
printf("The converted temperature is %.2lf\n", newFah);
break;
case 3:
printf("Exit \n");
break;
default:
printf("That is not a valid option \n");
break;
}
} while (choice != 3);
return 0;
}
Learn more on C program from:
https://brainly.com/question/23866418?referrer=searchResults
#SPJ4
Final answer:
Temperature conversion from Fahrenheit to Celsius is done using the formula T[°C] = (T[°F] - 32) × 5/9, and from Celsius to Fahrenheit using T[°F] = T[°C] × 9/5 + 32. The Celsius scale is also known as "centigrade" due to the 100-degree interval between the freezing and boiling points of water.
Explanation:
Converting Temperatures Between Celsius and Fahrenheit
To convert a temperature from degrees Fahrenheit to degrees Celsius, you use the following formula: T[°C] = (T[°F] - 32) × 5/9. For example, to convert 88°F to Celsius, subtract 32 from 88 and then multiply by 5/9. So, (88 - 32) × 5/9 = 56 × 5/9 = 31.11°C.
Conversely, to convert a temperature from degrees Celsius to degrees Fahrenheit, use the formula: T[°F] = T[°C] × 9/5 + 32. If you're in Spain and the weather forecast is 16°C, to convert to Fahrenheit, multiply 16 by 9/5 and add 32. Thus, 16 × 9/5 + 32 = 28.8 + 32 = 60.8°F.
The Celsius scale is sometimes called "centigrade" because it is based on 100 degrees between the freezing and boiling points of water.