Program for Fahrenheit to Kelvin conversion

Given a Temperature in Fahrenheit scale, our task is to convert it into Kelvin scale.

Examples :

Input : F = 100
Output : K = 311.278

Input : F = 110
Output : K = 316.833


The temperature conversion from Fahrenheit ( F ) to Kelvin ( K ) is given by the formula :

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

C++

filter_none

edit
close

play_arrow

link
brightness_4
code

// CPP program to convert temperature from
// Fahrenheit to Kelvin
#include<iostream>
using namespace std ;
  
// Function to convert temperature from degree 
// Fahrenheit to Kelvin
float Fahrenheit_to_Kelvin( float F )
{
    return 273.5 + ((F - 32.0) * (5.0/9.0));
}
  
// Driver function
int main()
{
    float F = 100;
    cout << "Temperature in Kelvin ( K ) = "
          << Fahrenheit_to_Kelvin( F ) ;
    return 0;
}

chevron_right


Java

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java program to convert temperature
// from Fahrenheit to Kelvin
class GFG
{
  
// Function to convert temperature  
// from degree Fahrenheit to Kelvin
static float Fahrenheit_to_Kelvin( float F )
{
    return 273.5f + ((F - 32.0f) * (5.0f/9.0f));
}
  
// Driver code
public static void main(String arg[])
{
    float F = 100;
    System.out.print("Temperature in Kelvin ( K ) = "
                    + (Math.round(Fahrenheit_to_Kelvin( F )
                                        *1000.0)/1000.0)) ;
}
}
// This code is contributed by Anant Agarwal.

chevron_right


Python

filter_none

edit
close

play_arrow

link
brightness_4
code

# Python program to convert temperature from
# Fahrenheit to Kelvin
  
# Function to convert temperature
def Fahrenheit_to_Kelvin(F):
    return 273.5 + ((F - 32.0) * (5.0/9.0))
  
# Driver function
F = 100
print("Temperature in Kelvin ( K ) = {:.3f}" 
            .format(Fahrenheit_to_Kelvin( F )))

chevron_right


C#

filter_none

edit
close

play_arrow

link
brightness_4
code

// C# program to convert temperature
// from Fahrenheit to Kelvin
using System;
  
class GFG
{
  
// Function to convert temperature 
// from degree Fahrenheit to Kelvin
static float Fahrenheit_to_Kelvin( float F )
{
    return 273.5f + ((F - 32.0f) *
                    (5.0f/9.0f));
}
  
// Driver code
public static void Main()
{
    float F = 100;
    Console.WriteLine("Temperature in Kelvin (K) = "
                    + (Math.Round(Fahrenheit_to_Kelvin(F)
                                        *1000.0)/1000.0)) ;
}
}
  
// This code is contributed by vt_m.

chevron_right


PHP

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
// PHP program to convert temperature
// from Fahrenheit to Kelvin
  
// Function to convert temperature 
// from degree  Fahrenheit to Kelvin
function Fahrenheit_to_Kelvin( $F )
{
    return 273.5 + (($F - 32.0) * 
                    (5.0 / 9.0));
}
  
    // Driver Code
    $F = 100;
    $x = number_format(Fahrenheit_to_Kelvin($F), 3);
    echo "Temperature in Kelvin ( K ) = ".$x;
      
// This code is contributed by Sam007
?>

chevron_right



Output :

Temperature in Kelvin ( K ) = 311.278


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



Improved By : vt_m, Sam007



Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.