Program to convert temperature from degree Celsius to Kelvin

24 May, 2022
Given temperature in degree Celsius, convert it into to Kelvin . Examples:  
Input : C = 100
Output : k = 373.15

Input : C = 110
Output : k = 383.15
 
Formula for converting temperature in degree Celsius to kelvin-  
K = ( °C + 273.15 )
0 °C = 273.15 kelvin
Below is the program for temperature conversion:  
C
C++
Java
Python3
C#
PHP
Javascript
/* C Program to convert temperature from celsius to kelvin */#include <stdio.h> // function takes value in celsius and returns value in kelvinfloat celsius_to_kelvin(float c){  return (c + 273.15);} int main(){   // variable of type float holds value in celsius  float c = 50;   // passing 'c' as parameter to the function  // printing the value in kelvin  printf("Temperature in Kelvin(K) : %0.2f",celsius_to_kelvin(c));  return 0;}
// CPP program to convert temperature// from degree Celsius to kelvin#include <bits/stdc++.h>using namespace std; // function to convert temperature// from degree Celsius to Kelvinfloat Celsius_to_Kelvin(float C){    return (C + 273.15);} // driver functionint main(){    // variable to hold the    // temperature in Celsius    float C = 100;     cout << "Temperature in Kelvin ( K ) = "         << Celsius_to_Kelvin(C);         return 0;}
// Java program to convert temperature// from degree Celsius to kelvinimport java.io.*; class GFG {    // function to convert temperature    // from degree Celsius to Kelvin    static float Celsius_to_Kelvin(float C)    {        return (float)(C + 273.15);    }         // Driver function    public static void main (String[] args)    {        // variable to hold the        // temperature in Celsius        float C = 100;             System .out.println ( "Temperature in Kelvin ( K ) = "                             + Celsius_to_Kelvin(C));                 }} // This code is contributed by vt_m.
# Python3 program to convert temperature# from degree Celsius to kelvin # Function to convert temperature# from degree Celsius to Kelvindef Celsius_to_Kelvin(C):    return (C + 273.15) # Driver Code # variable to hold the# temperature in CelsiusC = 100 print("Temperature in Kelvin ( K ) = ",                    Celsius_to_Kelvin(C))                     # This code is contributed by Anant Agarwal.
// C# program to convert temperature// from degree Celsius to kelvinusing System; class GFG {         // function to convert temperature    // from degree Celsius to Kelvin    static float Celsius_to_Kelvin(float C)    {        return (float)(C + 273.15);    }     // Driver function    public static void Main()    {        // variable to hold the        // temperature in Celsius        float C = 100;         Console.WriteLine("Temperature in Kelvin ( K ) = " +                                       Celsius_to_Kelvin(C));    }} // This code is contributed by vt_m.
<?php// PHP program to convert temperature// from degree Celsius to kelvin // function to convert temperature// from degree Celsius to Kelvinfunction Celsius_to_Kelvin( $C){    return ($C + 273.15);}     // Driver Code         // variable to hold the    // temperature in Celsius    $C = 100;    echo "Temperature in Kelvin ( K ) = "        , Celsius_to_Kelvin($C);         // This code is contributed by anuj_67.?>
<script> // Javascript program to convert temperature// from degree Celsius to kelvin // function to convert temperature// from degree Celsius to Kelvinfunction Celsius_to_Kelvin(C){    return (C + 273.15);} // driver function     // variable to hold the    // temperature in Celsius    let C = 100;     document.write("Temperature in Kelvin ( K ) = "        + Celsius_to_Kelvin(C)); // This code is contributed Mayank Tyagi </script>
Output: 
Temperature in Kelvin ( K ) = 373.15
Time Complexity: O(1), as we are not using any loops.
Auxiliary Space: O(1), as we are not using any extra space.
vt_m
mayanktyagi1709
sonawanejaydeep11
sweetyty
rohitsingh07052
School Programming
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Introduction To PYTHON
Interfaces in Java
Operator Overloading in C++
Polymorphism in C++
Types of Operating Systems
Constructors in Java
Exceptions in Java
Friend class and function in C++
Different Methods to Reverse a String in C++
Python program to check if a string is palindrome or not