Temperature conversion: Different temperature units are Celsius, Fahrenheit, Kelvin. Using mathematical formula we write C Program to convert Fahrenheit to Celsius and Fahrenheit to Kelvin.
There is a different formula for Temperature conversion which are as follow :
Temperature conversion formula
1. Formula used for converting Fahrenheit to Celsius
(F-32) * 5/9;

2. Formula used for converting Celsius to Fahrenheit formula (c to f)
(C * 9/5)+32

3. Formula used for converting celsius to kelvin formula
C + 273.15

4. Formula used for converting kelvin to Fahrenheit is as follow,
( K – 273.15 ) * 9/5 + 32

5. The formula used for converting kelvin to Celsius ( kelvin to celsius formula)
K – 273.15

C Program to convert Fahrenheit to Celsius and Fahrenheit to Kelvin

#include<stdio.h>
void main()
{
int from ,to ;

float value;

printf("temperature conversion \n");

printf("Enter no of unit to convert from : \n 1.Celsius \n2.Fahrenheit \n 3. kelvin\n");

scanf("%d",&from);

printf("Enter no of unit to convert to : \n 1. Celsius \n2.Fahrenheit \n 3. kelvin\n");

scanf("%d",&to);

printf("Enter the value to convert:");

scanf("%d",&value);


/* converting given value from specified unit to kelvin */

switch(from)

{

case 1:

value=value + 273.15;

break;

case 2:

value = (value + 459.67 )* 5/9;

break;

case 3:

break;

default:

break;

}

/* Converting value from kelvin to specified value */

switch(to)

{

case 1:

value=value + 273.15;

break;

case 2:

value = (value) * 9/ 5-459.67;

break;

case 3:

break;

default:

break;
}
printf("converted value = %d ", value);
}

Output :

Temperature conversion

Write A Comment