OverIQ.com

C Program to convert the temperature in Fahrenheit to Celsius

Last updated on July 27, 2020


To convert temperature in degrees Fahrenheit to Celsius, we use the following formula:

\[
cel = \frac{5}{9} + (fah - 32)
\]

The following is a C program to convert temperature in Fahrenheit to Celsius:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
/*****************************************************************
 * C Program to convert the temperature in Fahrenheit to Celsius
 * 
 * Formula used: c = (5/9) * (f - 32)
******************************************************************/

#include<stdio.h> // include stdio.h

int main() 
{
    float fah, cel;

    printf("Enter a temp in fah: ");
    scanf("%f", &fah);

    cel = (5.0/9) * (fah - 32);

    printf("%.2f°F is same as %.2f°C", fah, cel);

    return 0;
}

Expected Output: 1st run:

1
2
Enter a temp in fah: 455
455.00°F is same as 235.00°C

2nd run:

1
2
Enter a temp in fah: 32
32.00°F is same as 0.00°C