C Program for Fahrenheit to Kelvin conversion

In this blog post, 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.

Example,

Input : F = 100
Output : K = 311.28


Input : F = 110
Output : K = 283.50

 

 

Formula to convert Fahrenheit to Kelvin:

Below is a formula for how you can convert Fahrenheit to Kelvin in your C Code.

K = 273.5 + ((F - 32.0) * (5.0/9.0))

 

 

C program to convert Fahrenheit to Kelvin:

The below program asks the user to enter the temperature in Fahrenheit. After getting the temperature in Fahrenheit from the user program convert it to Kelvin. So in simple words, we are following the below steps to convert temperature Fahrenheit to Kelvin:

  • Get the user-given temperature in Fahrenheit units.
  • Apply the formula Kelvin = (273.5 + ((F – 32.0) * (5.0/9.0))).
  • Now print the temperature 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

Recommended Post:

Leave a Reply

Your email address will not be published. Required fields are marked *