Solution Review: Temperature Conversion
This lesson discusses the solution to the challenge given in the previous lesson.
package mainimport ("fmt")// aliasing typetype Celsius float32type Fahrenheit float32// Function to convert celsius to fahrenheitfunc toFahrenheit(t Celsius) Fahrenheit {return Fahrenheit((t*9/5 )+ 32)}func main() {var tempCelsius Celsius = 100tempFahr := toFahrenheit(tempCelsius) // function callfmt.Printf("%f ˚C is equal to %f ˚F",tempCelsius,tempFahr)}
Get hands-on with 1400+ tech skills courses.