C Program to Convert Fahrenheit to Celsius

How to write a C program to convert Fahrenheit to Celsius with an example. The mathematical formula behind the temperature conversion from degree Fahrenheit to Celsius in C is: Celsius = (5 / 9) * (Fahrenheit – 32)

C Program to Convert Fahrenheit to Celsius

This C program to convert Fahrenheit to Celsius lets the user enter the temperature value in Fahrenheit. Next, using the Fahrenheit to celsius formula, we are going to convert the user-specified temperature in Fahrenheit to Celsius in C.

//C program to convert Fahrenheit to Celsius
#include <stdio.h>
 
int main()
{
    float celsius, fahrenheit;
 
    printf("Please Enter the temperature in Fahrenheit: \n");
    scanf("%f", &fahrenheit);
 
    // Convert th temperature from fahrenheit to celsius formula
    celsius = (fahrenheit - 32) * 5 / 9;
    //celsius = 5 * (fahrenheit - 32) / 9;
    //celsius = (fahrenheit - 32) * 0.55556; 

    printf("\n %.2f Fahrenheit = %.2f Celsius", fahrenheit, celsius);
 
    return 0;
}
C program to convert Fahrenheit to Celsius 1

Within this C program to change Fahrenheit to Celsius example, the following statements will ask the user to enter the temperature value in Fahrenheit. Next, the scanf statement will assign the user entered values to declare variable already Fahrenheit.

printf("Please Enter the temperature in Fahrenheit: \n");
scanf("%f", &fahrenheit);

We can use any of the below-specified Fahrenheit to celsius formula to convert the temperature in Fahrenheit to Celsius

celsius = (fahrenheit – 32) * 5 / 9;
celsius = 5 * (fahrenheit – 32) / 9;
Or, celsius = (fahrenheit – 32) * 0.55556;

The last C Programming printf statement will print the output

printf("\n %.2f Fahrenheit = %.2f Celsius", fahrenheit, celsius);

Let me show you the Celsius value of 32 degrees Fahrenheit.

Please Enter the temperature in Fahrenheit: 
32

 32.00 Fahrenheit = 0.00 Celsius