To find the maximum of three numbers in Go, you can use a simple comparison with if statements.
In this example,
a
, b
, and c
with the numbers to compare.package main
import (
"fmt"
)
func main() {
a := 5
b := 8
c := 3
max := a
if b > max {
max = b
}
if c > max {
max = c
}
fmt.Printf("Maximum of three numbers is: %d\n", max)
}
Maximum of three numbers is: 8
In this tutorial, we learned How to find the Maximum of Three Numbers in Go language with well detailed examples.