Go Program to find the largest number among three numbers
In this program, you will learn how to find the largest number among the three numbers in Go.
10 20 30 => 30
10 20 12 => 20
Example: How to find the largest number among the three numbers in Go
package main
import "fmt"
func main() {
var x, y, z int
fmt.Print("Enter three numbers:")
fmt.Scan(&x, &y, &z)
if x > y && x > z {
fmt.Println("Largest is:", x)
} else if y > z {
fmt.Println("Largest is:", y)
} else {
fmt.Println("Largest is:", z)
}
}
Output:
Enter three numbers:10 30 20
Largest is: 30