In this exercise, we learn how to write a C program to convert Fahrenheit to Kelvin ?. We will write the C program to convert Fahrenheit to Kelvin. Write a C program to input temperature in Fahrenheit and convert it to Kelvin. How to convert temperature from degree Fahrenheit to degree Kelvin in C programming. Logic to convert temperature from Fahrenheit to Kelvin in C.
The below program ask the user to enter the temperature in Fahrenheit. After getting the temperature in Fahrenheit from the user program convert it in Kelvin.
#include <stdio.h>
float convertFahKelvin(float F )
{
return 273.5 + ((F - 32.0) * (5.0/9.0));
}
int main()
{
float kelvin, fahrenheit;
printf("Enter temperature in fahrenheit: ");
scanf("%f", &fahrenheit);
//called function to convert fahrenheit to kelvin
kelvin = convertFahKelvin(fahrenheit);
printf("%.2f Fahrenheit = %.2f Kelvin",fahrenheit,kelvin);
return 0;
}
Output:
Enter temperature in Fahrenheit: 100 100.00 Fahrenheit = 311.28 Kelvin
The below program ask the user to enter the temperature in Fahrenheit. After getting the temperature in Fahrenheit from the user program convert it in Kelvin.
Output:
Enter temperature in Fahrenheit: 100
need an explanation for this answer? contact us directly to get an explanation for this answer100.00 Fahrenheit = 311.28 Kelvin