Created
February 18, 2020 15:56
-
-
Save juliakm/d08da4fefb26c7563c85e0e80f4fece5 to your computer and use it in GitHub Desktop.
functions-temp.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
// kelvinToCelsius converts °K to °C | |
func kelvinToCelsius(k float64) float64 { | |
return k - 273.15 | |
} | |
func CelsiusToFahrenheit(c float64) float64 { | |
return (c * 9.0 / 5.0) + 32.0 | |
} | |
func kelvinToFahrenheit(k float64) float64 { | |
return CelsiusToFahrenheit(kelvinToCelsius(k)) | |
} | |
func main() { | |
fmt.Printf("233° K is %.2f° C\n", kelvinToCelsius(233)) | |
fmt.Printf("0° K is %.2f° F\n", kelvinToFahrenheit(0)) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment