Using the CelsiusToKelvin function as a guide, create a new function, changing the name to KelvinToCelsius, and modifying the function accordingly.
#include <iostream>
using namespace std;
float CelsiusToKelvin(float cel)
{
return cel + 273.15;
}
float KelvinToCelsius(float kel)
{
return kel - 273.15;
}
int main()
{
float kel, cel;
cout << "Please, enter temperature in Kelvin to get in Celsius: ";
cin >> kel;
cout << "The temperature in Celsius is " << KelvinToCelsius(kel) << endl;
cout << "Please, enter temperature in Celsius to get in Kelvin: ";
cin >> cel;
cout << "The temperature in Celsius is " << CelsiusToKelvin(cel);
}
Comments
Leave a comment