C Program to Convert Celsius to Kelvin

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

Celsius and Kelvin are two temperature scales used to measure hotness and coldness of an object. 

  • 0 degree Celsius = 273.15 Kelvin

The conversion of Celsius to Kelvin is done using the formula: Kelvin = Celsius + 273.15. We will be using this formula in our program for the conversion.

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

C Program to Convert Celsius to Kelvin

// C Program to Convert Celsius to Kelvin
#include <stdio.h>
int main(){
    float celsius, kelvin;
    
    // Asking for input
    printf("Enter the temperature in Celsius: ");
    scanf("%f", &celsius);
    
    // Converting celsius to kelvin
    kelvin = celsius + 273.15;
    
    // Displaying output
    printf("%.2f Celsius = %.2f Kelvin", celsius, kelvin);
    return 0;
}

Output

Enter the temperature in Celsius: 36.40
36.40 Celsius = 309.55 Kelvin

How Does This Program Work ?

    float celsius, kelvin;

In this program, we have declared two floating data type variables named celsius and kelvin.

    // Asking for input
    printf("Enter the temperature in Celsius: ");
    scanf("%f", &celsius);

The user is asked to enter the temperature in degree Celsius.

    // Converting celsius to kelvin
    kelvin = celsius + 273.15;

We convert the temperature from degree Celsius to Kelvin using the formula: K = C+ 27.15.

    // Displaying output
    printf("%.2f Celsius = %.2f Kelvin", celsius, kelvin);

Finally, the temperature in Kelvin is printed on the screen using printf() function. 

Conclusion

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

If you have any doubt regarding the program, then contact us in the comment section. We will be delighted to solve your doubts.

Leave a Comment

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