Convert celsius to kelvin

Here given code implementation process.

//C Program 
//Convert  celsius to kelvin
#include <stdio.h>

//Find the kelvin of given celsius
void celsius_to_kelvin(double celsius)
{
	// Formula : celsius + 273.15
	// Calculate given celsius to kelvin 
	double kelvin = celsius + 273.15;
	//Display result
	printf("Celsius : %lf  Kelvin : %lf\n", celsius, kelvin);
}
int main()
{
	//Simple test
	celsius_to_kelvin(1);
	celsius_to_kelvin(10.80);
	celsius_to_kelvin(14.50);
	return 0;
}

Output

Celsius : 1.000000  Kelvin : 274.150000
Celsius : 10.800000  Kelvin : 283.950000
Celsius : 14.500000  Kelvin : 287.650000
/*
  C++ program
  Convert  celsius to kelvin
*/
#include<iostream>

using namespace std;
class MyMath
{
	public:
		//Find the kelvin of given celsius
		void celsius_to_kelvin(double celsius)
		{
			// Formula : celsius + 273.15
			// Calculate given celsius to kelvin 
			double kelvin = celsius + 273.15;
			cout << "Celsius : " << celsius << " Kelvin : " << kelvin << "\n";
		}
};
int main()
{
	MyMath obj = MyMath();
	//Simple test
	obj.celsius_to_kelvin(1);
	obj.celsius_to_kelvin(10.80);
	obj.celsius_to_kelvin(14.50);
	return 0;
}

Output

Celsius : 1 Kelvin : 274.15
Celsius : 10.8 Kelvin : 283.95
Celsius : 14.5 Kelvin : 287.65
/*
  Java program
  Convert the celsius to kelvin
*/
class MyMath
{
	//Find the kelvin of given celsius
	public void celsius_to_kelvin(double celsius)
	{
		// Formula : celsius + 273.15
		// Calculate given celsius to kelvin 
		double kelvin = celsius + 273.15;
		System.out.print("Celsius : " + celsius + " Kelvin : " + kelvin + "\n");
	}
	public static void main(String[] args)
	{
		MyMath obj = new MyMath();
		//Simple test
		obj.celsius_to_kelvin(1);
		obj.celsius_to_kelvin(10.80);
		obj.celsius_to_kelvin(14.50);
	}
}

Output

Celsius : 1.0 Kelvin : 274.15
Celsius : 10.8 Kelvin : 283.95
Celsius : 14.5 Kelvin : 287.65
/*
  C# program
  Convert  celsius to kelvin
*/
using System;
class MyMath
{
	//Find the kelvin of given celsius
	public void celsius_to_kelvin(double celsius)
	{
		// Formula : celsius + 273.15
		// Calculate given celsius to kelvin 
		double kelvin = celsius + 273.15;
		Console.Write("Celsius : " + celsius + " Kelvin : " + kelvin + "\n");
	}
	public static void Main(String[] args)
	{
		MyMath obj = new MyMath();
		//Simple test
		obj.celsius_to_kelvin(1);
		obj.celsius_to_kelvin(10.80);
		obj.celsius_to_kelvin(14.50);
	}
}

Output

Celsius : 1 Kelvin : 274.15
Celsius : 10.8 Kelvin : 283.95
Celsius : 14.5 Kelvin : 287.65
#   Python 3 program
#   Convert celsius to kelvin

class MyMath :
	# Find the kelvin of given celsius
	def celsius_to_kelvin(self, celsius) :
		#  Formula : celsius + 273.15
		#  Calculate given celsius to kelvin 
		kelvin = celsius + 273.15
		print("Celsius : ", celsius ," Kelvin : ", kelvin ,"\n", end = "")
	

def main() :
	obj = MyMath()
	# Simple test
	obj.celsius_to_kelvin(1)
	obj.celsius_to_kelvin(10.80)
	obj.celsius_to_kelvin(14.50)

if __name__ == "__main__": main()

Output

Celsius :  1  Kelvin :  274.15
Celsius :  10.8  Kelvin :  283.95
Celsius :  14.5  Kelvin :  287.65
#   Ruby program
#   Convert celsius to kelvin

class MyMath

	# Find the kelvin of given celsius
	def celsius_to_kelvin(celsius)
	
		#  Formula : celsius + 273.15
		#  Calculate given celsius to kelvin 
		kelvin = celsius + 273.15
		print("Celsius : ", celsius ," Kelvin : ", kelvin ,"\n")
	end
end
def main()

	obj = MyMath.new()
	# Simple test
	obj.celsius_to_kelvin(1)
	obj.celsius_to_kelvin(10.80)
	obj.celsius_to_kelvin(14.50)
end
main()

Output

Celsius : 1 Kelvin : 274.15
Celsius : 10.8 Kelvin : 283.95
Celsius : 14.5 Kelvin : 287.65
/*
  Scala program
  Convert celsius to kelvin
*/
class MyMath
{
	//Find the kelvin of given celsius
	def celsius_to_kelvin(celsius: Double): Unit = {
		// Formula : celsius + 273.15
		// Calculate given celsius to kelvin 
		var kelvin: Double = celsius + 273.15;
		print("Celsius : " + celsius + " Kelvin : " + kelvin + "\n");
	}
}
object Main
{
	def main(args: Array[String]): Unit = {
		var obj: MyMath = new MyMath();
		//Simple test
		obj.celsius_to_kelvin(1);
		obj.celsius_to_kelvin(10.80);
		obj.celsius_to_kelvin(14.50);
	}
}

Output

Celsius : 1.0 Kelvin : 274.15
Celsius : 10.8 Kelvin : 283.95
Celsius : 14.5 Kelvin : 287.65
/*
  Swift program
  Convert celsius to kelvin
*/
class MyMath
{
	//Find the kelvin of given celsius
	func celsius_to_kelvin(_ celsius: Double)
	{
		// Formula : celsius + 273.15
		// Calculate given celsius to kelvin 
		let kelvin: Double = celsius + 273.15;
		print("Celsius : ", celsius ," Kelvin : ", kelvin ,"\n", terminator: "");
	}
}
func main()
{
	let obj: MyMath = MyMath();
	//Simple test
	obj.celsius_to_kelvin(1);
	obj.celsius_to_kelvin(10.80);
	obj.celsius_to_kelvin(14.50);
}
main();

Output

Celsius :  1.0  Kelvin :  274.15
Celsius :  10.8  Kelvin :  283.95
Celsius :  14.5  Kelvin :  287.65
<?php
/*
  Php program
  Convert celsius to kelvin
*/
class MyMath
{
	//Find the kelvin of given celsius
	public	function celsius_to_kelvin($celsius)
	{
		// Formula : celsius + 273.15
		// Calculate given celsius to kelvin 
		$kelvin = $celsius + 273.15;
		echo "Celsius : ". $celsius ." Kelvin : ". $kelvin ."\n";
	}
}

function main()
{
	$obj = new MyMath();
	//Simple test
	$obj->celsius_to_kelvin(1);
	$obj->celsius_to_kelvin(10.80);
	$obj->celsius_to_kelvin(14.50);
}
main();

Output

Celsius : 1 Kelvin : 274.15
Celsius : 10.8 Kelvin : 283.95
Celsius : 14.5 Kelvin : 287.65
/*
  Node Js program
  Convert celsius to kelvin
*/
class MyMath
{
	//Find the kelvin of given celsius
	celsius_to_kelvin(celsius)
	{
		// Formula : celsius + 273.15
		// Calculate given celsius to kelvin 
		var kelvin = celsius + 273.15;
		process.stdout.write("Celsius : " + celsius + " Kelvin : " + kelvin + "\n");
	}
}

function main()
{
	var obj = new MyMath();
	//Simple test
	obj.celsius_to_kelvin(1);
	obj.celsius_to_kelvin(10.80);
	obj.celsius_to_kelvin(14.50);
}
main();

Output

Celsius : 1 Kelvin : 274.15
Celsius : 10.8 Kelvin : 283.95
Celsius : 14.5 Kelvin : 287.65

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

New Comment







© 2021, kalkicode.com, All rights reserved