C Program to Convert Centigrade to Fahrenheit

C program to convert Centigrade to Fahrenheit can be implemented by using the following formula:


$F = 32+\frac{9*C}{5}$


Here, the 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 Fahrenheit ($^{\circ}F$) while taking Centigrade ($^{\circ}C$) as input.

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






1. Algorithm to convert centigrade to fahrenheit


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

2. Compute $f= 32+\frac{9*C}{5}$

3. Return $f$





2. Pseudocode to convert centigrade to fahrenheit


Input : Temperature $c$ in centigrade

Output :Temperature $c$ in fahrenheit

1. Procedure convert($c$):

2. $f \leftarrow 32+\frac{9*C}{5}$

3. Return $f$

4. End Procedure





3. Time complexity to convert centigrade to fahrenheit


Time Complexity: O(1)





4. C Program & output to convert centigrade to fahrenheit

Code has been copied
/**********************************************
            alphabetacoder.com
 C program to convert Centigrade to Fahrenheit
***********************************************/

#include <stdio.h>

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

    //convert Centigrade to Fahrenheit
    f = 32 + (9 * c) / 5;

    printf("Temperature in Fahrenheit = %lf", f);
    return 0;
}

Output


Enter the temperature in Centigrade = 82.5

Temperature in Fahrenheit = 180.500000