C program to convert Fahrenheit to celsius

In this article, we are going to learn how to convert temperature from degrees Fahrenheit to celsius using C language programs. This program will help you to enter the temperature in Fahrenheit and then convert it to celsius vice-versa

Formula to convert Fahrenheit to celsius


The formula that we are going to use in this program is:

celsius = (fahrenheit - 32) * 5 / 9

Where

  • Fahrenheit – This is the temperature in Fahrenheit which user will enter to do the conversion.
  • celsius – This is the temperature in celsius degree we will get after conversion.

Using this simple formula, we will perform the calculation with C language logic and syntaxes. We will take input from the user in Fahrenheit degree, then perform the logic as per the above formula. Finally, display the calculated results. so let us see this in action in the C language program below.

C program to convert Fahrenheit to celsius


#include <stdio.h>

int main()
{
    float celsius, fahrenheit;

    
    printf("Please enter the temperature in Fahrenheit to convert to Celsius: ");
    scanf("%f", &fahrenheit);

    
    celsius = (fahrenheit - 32) * 5 / 9;

    
    printf("The Temprature %.2f Fahrenheit is equal to %.2f in Celsius", fahrenheit, celsius);

    return 0;
}

Output

Please enter the temperature in Fahrenheit to convert to Celsius: 40
The Temprature 40.00 Fahrenheit is equal to 4.44 in Celsius