{"id":4350,"date":"2022-12-16T16:29:06","date_gmt":"2022-12-16T16:29:06","guid":{"rendered":"https:\/\/gyanipandit.com\/programming\/?p=4350"},"modified":"2022-12-16T16:29:07","modified_gmt":"2022-12-16T16:29:07","slug":"c-program-to-convert-celsius-to-kelvin","status":"publish","type":"post","link":"https:\/\/gyanipandit.com\/programming\/c-program-to-convert-celsius-to-kelvin\/","title":{"rendered":"C program to convert Celsius to Kelvin"},"content":{"rendered":"\n<p>In this article, we are going to discuss how to convert the temperature from celsius to kelvin. Before starting the main program, we have to know about the basic formula to convert the temperature from celsius to kelvin.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">C program to convert celsius to kelvin<\/h2>\n\n\n\n<p>For example &#8211;<\/p>\n\n\n\n<p><strong>Input-<\/strong><\/p>\n\n\n\n<p>So first step we are going to take input from the user in the form of celsius. Suppose we take 200 as user input.<\/p>\n\n\n\n<p><strong>Logic-<\/strong><\/p>\n\n\n\n<p>So to calculate the temperature from celsius to kelvin we have to know about the logic behind it.<\/p>\n\n\n\n<p>So basically the formula is :<\/p>\n\n\n\n<p>kelvin = celsius + 273.15<\/p>\n\n\n\n<p><strong>Output-<\/strong><\/p>\n\n\n\n<p>According to our input, we get output as<\/p>\n\n\n\n<p>Enter the temperature in celsius:200<br>The temperature in kelvin is 473.149994<\/p>\n\n\n\n<p>By using the above formula we are going to convert the temperature from celsius to kelvin so let&#8217;s try to implement this above formula in our program.<\/p>\n\n\n\n<p><strong>Method -1<\/strong><\/p>\n\n\n\n<p>#C program to convert the temperature from celsius to kelvin<\/p>\n\n\n\n<p class=\"has-white-color has-black-background-color has-text-color has-background\">#include&lt;stdio.h&gt;<br>int main()<br>{<br>float celsius, kelvin;<br>printf(&#8220;Enter the temperature in celsius :&#8221; );<br>scanf(&#8220;%f&#8221;, &amp;celsius);<br>kelvin = celsius + 273.15;<br>printf(&#8220;Temperature in kelvin is %f&#8221;, kelvin);<br>return 0;<br>}<\/p>\n\n\n\n<p><strong>Output :<\/strong><\/p>\n\n\n\n<p>Enter the temperature in celsius:200<br>The temperature in kelvin is 473.149994<\/p>\n\n\n\n<p>The above program is very simple to convert the temperature from celsius to kelvin, but now we are going to learn this program by using the user-define function so let&#8217;s start!<\/p>\n\n\n\n<p><strong>Method 2<\/strong><\/p>\n\n\n\n<p>\/\/ C program to convert the temperature from celsius to kelvin<\/p>\n\n\n\n<p class=\"has-white-color has-black-background-color has-text-color has-background\">#include&lt;stdio.h&gt;<br>float temperature(float celsius){<br>return (celsius + 273.15);<br>}<br>int main()<br>{<br>float celsius, kelvin;<br>printf(&#8220;Enter the temperature in celsius :&#8221; );<br>scanf(&#8220;%f&#8221;, &amp;celsius);<br>printf(&#8220;Temperature in kelvin is %f&#8221;,temperature(celsius));<br>return 0;<br>}<\/p>\n\n\n\n<p><strong>Output :<\/strong><\/p>\n\n\n\n<p>Enter the temperature in celsius:20 <br>The temperature in kelvin is 293.149994<\/p>\n\n\n\n<p>In this above program, we can see that we simply use a user-defined function in it. Where we give the name temperature to the function after that we simply give a parameter to the function that is kelvin after that we simply apply the formula. In this way, we simply use user-defined functions. And by using these we simply get our final output.<\/p>\n\n\n\n<p>I hope these two methods are going to be helpful for you. Whenever you want to calculate the temperature from celsius to kelvin in the c program. Then you can simply use this method to convert the temperature from kelvin to celsius.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we are going to discuss how to convert the temperature from celsius to kelvin. Before starting the main program, we have to know about the basic formula to convert the temperature from celsius to kelvin. C program to convert celsius to kelvin For example &#8211; Input- So first step we are going [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30],"tags":[29,54],"class_list":{"0":"post-4350","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-c-program","7":"tag-c-program","8":"tag-c-program-to-convert-celsius-to-kelvin"},"_links":{"self":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/4350","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/comments?post=4350"}],"version-history":[{"count":1,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/4350\/revisions"}],"predecessor-version":[{"id":4351,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/4350\/revisions\/4351"}],"wp:attachment":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/media?parent=4350"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/categories?post=4350"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/tags?post=4350"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}