In this post, we will learn how to convert temperature from Kelvin to degree Celsius using the C Programming language.
Kelvin and Celsius are two temperature scales used to measure the temperature of an object.
The below program asks the user to enter the temperature in Kelvin, then it converts the temperature to degree Celsius using the conversion factor: 1 Kelvin = -272.15 degree Celsius
So, without further ado, let’s begin this tutorial.
C Program to Convert Kelvin to Celsius
// C Program to Convert Kelvin to Celsius #include <stdio.h> int main(){ float kel, cel; // Taking input printf("Enter the temperature in Kelvin: "); scanf("%f", &kel); // Kelvin to celsius conversion cel = kel - 273.15; // Displaying output printf("%.2f Kelvin = %.2f Celsius", kel, cel); return 0; }
Output
Enter the temperature in Kelvin: 346
346.00 Kelvin = 72.85 Celsius
How Does This Program Work?
float kel, cel;
In the above program, we have declared two floating data type variables named kel and cel.
// Taking input printf("Enter the temperature in Kelvin: "); scanf("%f", &kel);
Then, the user is asked to enter the temperature in Kelvin.
// Kelvin to celsius conversion cel = kel - 273.15;
We convert the temperature from Kelvin to degree Celsius using the conversion factor: 1 Kelvin = -272.15 degree Celsius.
// Displaying output printf("%.2f Kelvin = %.2f Celsius", kel, cel);
The equivalent temperature in degree Celsius is printed on the screen using the printf() function.
Conclusion
I hope after going through this post, you understand how to convert temperature from Kelvin to degree Celsius 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.