Here is a C program to convert temperature from fahrenheit to celsius. Given a temperature in Celsius, we have to convert it to fahrenheit and print it on screen. To convert celsius to fahrenheit, we will use below expression:
F =(9/5)*C + 32;
where, C is the temperature in Celsius and F is temperature in Fahrenheit.
C program to convert temperature from celsius to fahrenheit
#include<stdio.h> int main() { float fahren, celsius; printf("Enter the temperature in celsius\n"); scanf("%f", &celsius); fahren =(9.0/5.0) * celsius + 32; printf("%.2fC is equal to %.2fF\n", celsius, fahren); return 0; }Output
Enter the temperature in celsius 15 15.00C is equal to 59.00F
Enter the temperature in celsius 0 0.00C is equal to 32.00F
C program to convert temperature from fahrenheit to celsius
In this program, to convert fahreneheit to celsius we are using below expression:
C = (F - 32)*(5/9);
where, F is temperature in fahreneheit and C is temperature in celsius.
#include<stdio.h> int main() { float fahren, celsius; printf("Enter the temperature in fahrenheit\n"); scanf("%f", &fahren); celsius = 5 * (fahren - 32) / 9; printf("%.2fF is equal to %.2fC\n", fahren, celsius); return 0; }Output
Enter the temperature in fahrenheit 0 0.00F is equal to -17.78C
Enter the temperature in fahrenheit 98.6 98.60F is equal to 37.00C
Related Topics