C Program to Convert Fahrenheit to Celsius and Vice Versa

In this example, I shared the C program to convert Celsius to Fahrenheit, Also I explain each step the logic to convert temperature from Celsius to Fahrenheit. 

C program to convert Fahrenheit to Celsius and vice versa

Logic to convert Fahrenheit to Celsius

Here you learn about logic and formula used to convert Fahrenheit to celsius. The general formula for the conversion from cel is Celsius = (5 / 9) * (Fahrenheit – 32). In this, you have to enter the Fahrenheit then this mention formula is used by the C program to convert and the output will be shown on screen. 

Logic to convert Celsius to Fahrenheit

Here you learn about logic and formula used to convert celsius to Fahrenheit. The general formula for the conversion from Celsius to Fahrenheit is Fahrenheit = (Celsius * 9 / 5) + 32. and the result is store in variable Fahrenheit and then display it.

Program


#include<stdio.h>
 int main()
 {
   float fah,rcen,cen,rfah;
    printf("\n Enter the temperature in fahrenheit ");
    scanf("%f",&amp;fah);
    rcen=(0.55*fah)-32.0;
    printf("\n The temperature %f in fahrenheit is %f in celcius",fah,rcen);
    printf("\n Enter the temperature in celcius ");
    scanf("%f",&amp;cen);
    rfah=(1.8*cen)+32.0;
    printf("\n The temperature %f in celcius is %f in fahrenheit",cen,rfah);
   return 0;
 }

Output


Enter the temperature in Fahrenheit: 76
The temperature 76.000000 in Fahrenheit is 9.800000 in Celcius
Enter the temperature in Celcius: 37
The temperature 37.000000 in Celcius is 98.599998 in Fahrenheit
 
In this C program, I shared convert Fahrenheit to Celsius and convert Celsius to Fahrenheit with logic and formula.

Happy Coding 😊

If you have any doubts, Please let me know

Previous Post Next Post

Contact Form