Convert kelvin to celsius
Here given code implementation process.
//C Program
//Convert kelvin to celsius
#include <stdio.h>
//Find the celsius by given kelvin
void kelvin_to_celsius(double kelvin)
{
// Formula : kelvin - 273.15
// Calculate given kelvin to celsius
double celsius = kelvin - 273.15;
//Display result
printf("Kelvin : %lf Celsius : %lf\n", kelvin, celsius);
}
int main()
{
//Simple test
kelvin_to_celsius(1);
kelvin_to_celsius(1865);
kelvin_to_celsius(280.90);
return 0;
}
Output
Kelvin : 1.000000 Celsius : -272.150000
Kelvin : 1865.000000 Celsius : 1591.850000
Kelvin : 280.900000 Celsius : 7.750000
/*
Java program
Convert kelvin to celsius
*/
class MyMath
{
//Find the celsius by given kelvin
public void kelvin_to_celsius(double kelvin)
{
// Formula : kelvin - 273.15
// Calculate given kelvin to celsius
double celsius = kelvin - 273.15;
System.out.print("Kelvin : " + kelvin + " Celsius : " + celsius + "\n");
}
public static void main(String[] args)
{
MyMath obj = new MyMath();
//Simple test
obj.kelvin_to_celsius(1);
obj.kelvin_to_celsius(1865);
obj.kelvin_to_celsius(280.90);
}
}
Output
Kelvin : 1.0 Celsius : -272.15
Kelvin : 1865.0 Celsius : 1591.85
Kelvin : 280.9 Celsius : 7.75
/*
C# program
Convert kelvin to celsius
*/
using System;
class MyMath
{
//Find the celsius by given kelvin
public void kelvin_to_celsius(double kelvin)
{
// Formula : kelvin - 273.15
// Calculate given kelvin to celsius
double celsius = kelvin - 273.15;
Console.Write("Kelvin : " + kelvin + " Celsius : " + celsius + "\n");
}
public static void Main(String[] args)
{
MyMath obj = new MyMath();
//Simple test
obj.kelvin_to_celsius(1);
obj.kelvin_to_celsius(1865);
obj.kelvin_to_celsius(280.90);
}
}
Output
Kelvin : 1 Celsius : -272.15
Kelvin : 1865 Celsius : 1591.85
Kelvin : 280.9 Celsius : 7.75
/*
C++ program
Convert kelvin to celsius
*/
#include<iostream>
using namespace std;
class MyMath
{
public:
//Find the celsius by given kelvin
void kelvin_to_celsius(double kelvin)
{
// Formula : kelvin - 273.15
// Calculate given kelvin to celsius
double celsius = kelvin - 273.15;
cout << "Kelvin : " << kelvin << " Celsius : " << celsius << "\n";
}
};
int main()
{
MyMath obj ;
//Simple test
obj.kelvin_to_celsius(1);
obj.kelvin_to_celsius(1865);
obj.kelvin_to_celsius(280.90);
return 0;
}
Output
Kelvin : 1 Celsius : -272.15
Kelvin : 1865 Celsius : 1591.85
Kelvin : 280.9 Celsius : 7.75
<?php
/*
Php program
Convert kelvin to celsius
*/
class MyMath
{
//Find the celsius by given kelvin
public function kelvin_to_celsius($kelvin)
{
// Formula : kelvin - 273.15
// Calculate given kelvin to celsius
$celsius = $kelvin - 273.15;
echo "Kelvin : ". $kelvin ." Celsius : ". $celsius ."\n";
}
}
function main()
{
$obj = new MyMath();
//Simple test
$obj->kelvin_to_celsius(1);
$obj->kelvin_to_celsius(1865);
$obj->kelvin_to_celsius(280.90);
}
main();
Output
Kelvin : 1 Celsius : -272.15
Kelvin : 1865 Celsius : 1591.85
Kelvin : 280.9 Celsius : 7.75
/*
Node Js program
Convert kelvin to celsius
*/
class MyMath
{
//Find the celsius by given kelvin
kelvin_to_celsius(kelvin)
{
// Formula : kelvin - 273.15
// Calculate given kelvin to celsius
var celsius = kelvin - 273.15;
process.stdout.write("Kelvin : " + kelvin + " Celsius : " + celsius + "\n");
}
}
function main()
{
var obj = new MyMath();
//Simple test
obj.kelvin_to_celsius(1);
obj.kelvin_to_celsius(1865);
obj.kelvin_to_celsius(280.90);
}
main();
Output
Kelvin : 1 Celsius : -272.15
Kelvin : 1865 Celsius : 1591.85
Kelvin : 280.9 Celsius : 7.75
# Python 3 program
# Convert kelvin to celsius
class MyMath :
# Find the celsius by given kelvin
def kelvin_to_celsius(self, kelvin) :
# Formula : kelvin - 273.15
# Calculate given kelvin to celsius
celsius = kelvin - 273.15
print("Kelvin : ", kelvin ," Celsius : ", celsius ,"\n", end = "")
def main() :
obj = MyMath()
# Simple test
obj.kelvin_to_celsius(1)
obj.kelvin_to_celsius(1865)
obj.kelvin_to_celsius(280.90)
if __name__ == "__main__": main()
Output
Kelvin : 1 Celsius : -272.15
Kelvin : 1865 Celsius : 1591.85
Kelvin : 280.9 Celsius : 7.75
# Ruby program
# Convert kelvin to celsius
class MyMath
# Find the celsius by given kelvin
def kelvin_to_celsius(kelvin)
# Formula : kelvin - 273.15
# Calculate given kelvin to celsius
celsius = kelvin - 273.15
print("Kelvin : ", kelvin ," Celsius : ", celsius ,"\n")
end
end
def main()
obj = MyMath.new()
# Simple test
obj.kelvin_to_celsius(1)
obj.kelvin_to_celsius(1865)
obj.kelvin_to_celsius(280.90)
end
main()
Output
Kelvin : 1 Celsius : -272.15
Kelvin : 1865 Celsius : 1591.85
Kelvin : 280.9 Celsius : 7.75
/*
Scala program
Convert kelvin to celsius
*/
class MyMath
{
//Find the celsius by given kelvin
def kelvin_to_celsius(kelvin: Double): Unit = {
// Formula : kelvin - 273.15
// Calculate given kelvin to celsius
var celsius: Double = kelvin - 273.15;
print("Kelvin : " + kelvin + " Celsius : " + celsius + "\n");
}
}
object Main
{
def main(args: Array[String]): Unit = {
var obj: MyMath = new MyMath();
//Simple test
obj.kelvin_to_celsius(1);
obj.kelvin_to_celsius(1865);
obj.kelvin_to_celsius(280.90);
}
}
Output
Kelvin : 1.0 Celsius : -272.15
Kelvin : 1865.0 Celsius : 1591.85
Kelvin : 280.9 Celsius : 7.75
/*
Swift program
Convert kelvin to celsius
*/
class MyMath
{
//Find the celsius by given kelvin
func kelvin_to_celsius(_ kelvin: Double)
{
// Formula : kelvin - 273.15
// Calculate given kelvin to celsius
let celsius: Double = kelvin - 273.15;
print("Kelvin : ", kelvin ," Celsius : ", celsius ,"\n", terminator: "");
}
}
func main()
{
let obj: MyMath = MyMath();
//Simple test
obj.kelvin_to_celsius(1);
obj.kelvin_to_celsius(1865);
obj.kelvin_to_celsius(280.90);
}
main();
Output
Kelvin : 1.0 Celsius : -272.15
Kelvin : 1865.0 Celsius : 1591.85
Kelvin : 280.9 Celsius : 7.75
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