Skip to main content

C Program for Temperature conversion from Fahrenheit to Celsius and kelvin

To convert temperature from Fahrenheit to Celsius we are using formula as (temperature – 32) * (5/9)

To convert temperature from Fahrenheit to Celsius we are using formula as (temperature – 32) * (5/9) + 273.15

//Accept Temperature in fahrenheit (F) and print it in Celsius(C) acn Kelvin(K).
// fahrenheit to Celsius = (Temp°F − 32) × 5/9 = °C
// fahrenheit to kelvin = (Temp°F − 32) × 5/9 + 273.15 = 273.15K

#include<stdio.h>
#include<conio.h>

void main()
 {
   float F_Temp,C_Temp,K_Temp;// declaring variable as float as Temperature can be in decimal.
   printf("\n\t Enter Temperature in Fahrenheit: ");
   scanf("%f",&F_Temp);                        //%f Read float value
//Now converting F_Temp to Celsius and Kelvin
   C_Temp=(F_Temp-32.0)*(5.0/9.0);
   K_Temp=((F_Temp-32.0)*(5.0/9.0))+273.15;
   printf("\n\t Temperature in Celsius= %.2f °C",C_Temp);
   printf("\n\t Temperature in Kelvin = %.2f K",K_Temp);  //Printing results up to 2 decimal point

   getch();
 }

Output



	 Enter Temperature in Fahrenheit: 67



	Temperature in Celsius= 19.44 °C

	Temperature in Kelvin = 292.59 K

In Above program we can directly convert Celsius Temperature to Kelvin by adding 273.15k