C Program to Convert Fahrenheit to Kelvin

In this post, we will learn how to convert temperature from degree Celsius to Kelvin using the C Programming language.

We cannot convert the temperature from degree Fahrenheit to Kelvin, first we have to convert the temperature from degree Celsius to Degree Fahrenheit.

Then, we convert the temperature from degree Celsius to Kelvin.

The good thing is we can do all this process using a simple formula: Kelvin = ((Fahrenheit -32) * (5/9)) + 273.15.

We will use this formula in our program for the conversion.

So, without further ado, let’s begin this tutorial. 

Contents

C Program to Convert Fahrenheit to Kelvin

// C Program to Convert Fahrenheit to Kelvin
#include <stdio.h>
int main(){
    float F, kel;
    
    // Taking input
    printf("Enter the temperature in Fahrenheit: ");
    scanf("%f", &F);
    
    // Fahrenheit to kelvin conversion 
    kel = ((5.0 / 9) * (F - 32)) + 273.15;
    
    // Display output
    printf("%.2f degree Fahrenheit = %.2f Kelvin", F, kel);
    return 0;
}

Output

Enter the temperature in Fahrenheit: 98.6
98.60 degree Fahrenheit = 310.15 Kelvin

How Does This Program Work?

    float F, kel;

In this program, we have decorated two floating data type variables named F and kel.

    // Taking input
    printf("Enter the temperature in Fahrenheit: ");
    scanf("%f", &F);

The user is asked to enter the temperature in degree Fahrenheit. The entered value gets stored in the F named variable.

    // Fahrenheit to kelvin conversion 
    kel = ((5.0 / 9) * (F - 32)) + 273.15;

We convert the temperature from degree Fahrenheit to Kelvin using the formula: Kelvin = ((Fahrenheit -32) * (5/9)) + 273.15.

    // Display output
    printf("%.2f degree Fahrenheit = %.2f Kelvin", F, kel);

The result gets displayed on the screen using the printf() function.

Conclusion

I hope after going through this post, you understand how to convert temperature from degree Fahrenheit to Kelvin using the C Programming language.

If you have any doubts regarding the tutorial, then contact us in the comment section. We will be delighted to assist you.

Leave a Comment

Your email address will not be published.