C Program to Convert Fahrenheit to Centigrade

C program to convert fahrenheit to centigrade can be implemented by using following formula:

$C = \frac{(F-32)*5}{9}$

Here, value of $F$ is the temperature in fahrenheit while $C$ is the temperature in centigrade.

Fahrenheit and Centigrade are two well known temperature scales. Both of them are used regularly in daily temperature measurements. By using the above formula, the following C program produces output in celcius ($^{\circ}C$) while taking fahrenheit ($^{\circ}F$) as input.

The algorithm, pseudocode and time complexity of the program have also been provided.

1. Algorithm to convert fahrenheit to centigrade

    1. Take temperature in fahrenheit say $f$ as input.

    2. Compute $c= \frac{(f-32)*5}{9}$

    3. Return $c$

2. Pseudocode to convert fahrenheit to centigrade

Input : Temperature $f$ in fahrenheit

Output :Temperature $c$ in centigrade

1. Procedure convert($f$):

2. $c \leftarrow \frac{(f-32)*5}{9}$

3. Return $c$

4. End Procedure

3. Time complexity to convert fahrenheit to centigrade

Time Complexity: O(1)

4. C Program & output to convert fahrenheit to centigrade

Code has been copied
 C program to convert Fahrenheit to Centigrade

#include <stdio.h>

int main() {
    // declare variables
    double f, c;
    //take input in fahrenheit
    printf("Enter the temperature in Fahrenheit = ");
    scanf("%lf", & f);

    //convert fahrenheit and c
    c = 5 * (f - 32) / 9;

    printf("Temperature is %lf in centigrade When %lf in fahrenheit.", c, f);
    return 0;


Enter the temperature in fahrenheit = 212

Temperature is 100.000000 in centigrade When 212.000000 in fahrenheit.