In this program, you will learn about C program to convert temperature i.e degree Celsius into Fahrenheit and vice versa. Temperature conversion formula: F = ( 1.8. C) + 32 //celsius into fahrenheit C = ( F - 32 ) / 32 //fahrenheit into celsius.
In this blog post, we learn how to write a C program to convert Fahrenheit to celsius ?. We will write the C program to convert Fahrenheit to celsius. Write a C program to input temperature in Fahrenheit and convert it to Centigrade. How to convert temperature from degree Fahrenheit to degree centigrade in C programming. Logic to convert temperature from Fahrenheit to Celsius in C.
Example,
Formula to convert Fahrenheit to Celsius:
C program to convert Fahrenheit to Celsius:
The below program ask the user to enter the temperature in Fahrenheit. After getting the temperature in Fahrenheit from the user program convert it in Celsius.
Output:
Enter temperature in Fahrenheit: 32
32.00 Celsius = 0.00 Fahrenheit
C program to convert Fahrenheit to Celsius using a function:
The below program ask the user to enter the temperature in celsius. After getting the temperature in celsius from the user called a function name convertCelFahrenheit() to convert temperature from Celsius to Fahrenheit.
Output:
Enter temperature in Fahrenheit: 100
100.00 Fahrenheit = 37.78 Celsius
Write a generic C program which converts Celsius to Fahrenheit and vice versa:
We already know the formula to convert Celsius to Fahrenheit and Fahrenheit to Celsius. So let see a C program that asks the user choice and converts the temperature unit accordingly.
Output:
I have given here C++ Program source code to convert Fahrenheit to Celsius and Celsius to Fahrenheit.
The forumula for conversion is given below:
Dev C 2b 2b Fahrenheit To Celsius Conversion Chart
Celsius = (Fahrenheit - 32) * 5 / 9;
Fahrenheit = Celsius * (9 / 5) + 32;
Source Code
// FahrenheitCelsiusConverter.cpp : Implementation File
#include<stdio.h>
int main()
{
double val;
printf('Enter a number to use in Fahrenheit and Celsius Converter: ');
scanf('%lf', &val);
double Celsius = (val - 32.0) * 5.0 / 9.0;
double Fahrenheit = (val * (9.0 / 5.0) + 32);
printf('n%8.4lf %cF = %8.4lf %cCn', val, 248, Celsius, 248);
printf('%8.4lf %cC = %8.4lf %cFnn', val, 248, Fahrenheit, 248);
return 0;
}
Output
Enter a number to use in Fahrenheit and Celsius Converter: 100
100.0000 °F =37.7778 °C
100.0000 °C = 212.0000 °F
Press any key to continue . . .
Enter a number to use in Fahrenheit and Celsius Converter: -40
-40.0000 °F = -40.0000 °C
-40.0000 °C = -40.0000 °F
Press any key to continue . . .
Enter a number to use in Fahrenheit and Celsius Converter: 0
0.0000 °F = -17.7778 °C
0.0000 °C =32.0000 °F
Press any key to continue . . .
Enter a number to use in Fahrenheit and Celsius Converter: 28
28.0000 °F =-2.2222 °C
28.0000 °C =82.4000 °F
Press any key to continue . . .