204k views
3 votes
Programming In C:

Using the CelsiusToKelvin function as a guide, create a new function, changing the name to KelvinToCelsius, and modifying the function accordingly.

#include

double CelsiusToKelvin(double valueCelsius) {

double valueKelvin = 0.0;

valueKelvin = valueCelsius + 273.15;

return valueKelvin;

}

User JT Nolan
by
4.8k points

1 Answer

1 vote

Our function will simply be the inverse of the given one: celsius and kelvin degrees differ by 273.15. You add this number is you compute kelvin from celsius, and you subtract this number if you're going the other way around (which is what we're doing):

#include

double KelvinToCelsius(double valueKelvin ) {

double valueCelsius = 0.0;

valueCelsius = valueKelvin - 273.15;

return valueCelsius ;

}

User Steve Chaloner
by
5.3k points