Convert temperature in Fahrenheit to Centigrade
Temperature of a city in Fahrenheit degrees is input through the keyboard. Write a program in C to convert this temperature into Centigrade degrees.
Program
#include<stdio.h>
#include<conio.h>
void main()
{
float temp_f, temp_c;
printf("Enter the temperature in Fahrenhiet\t:");
scanf("%f",&temp_f);
temp_c = (temp_f - 32)*5/9;
printf("\nCorresponding temperature in Celsius is %f",temp_c);
getch();
}
Output
Enter the temperature in Fahrenhiet :98.6
Corresponding temperature in Celsius is 37.000000
Explanation
In this program, temperature in farenheit is taken as an input from user and stored in variable named 'temp_f'. To convert the temperature from farenheit to celsius following formula is used and result is stored in variable named 'temp_c'
temp_c = (temp_f - 32)*5/9;