Solution Review: Temperature Conversion

This lesson discusses the solution to the challenge given in the previous lesson.

package main
import (
"fmt"
)
// aliasing type
type Celsius float32
type Fahrenheit float32
// Function to convert celsius to fahrenheit
func toFahrenheit(t Celsius) Fahrenheit {
return Fahrenheit((t*9/5 )+ 32)
}
func main() {
var tempCelsius Celsius = 100
tempFahr := toFahrenheit(tempCelsius) // function call
fmt.Printf("%f ËšC is equal to %f ËšF",tempCelsius,tempFahr)
}

Get hands-on with 1200+ tech skills courses.