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

Xiith is created for educational, experimental, and schooling purpose. Examples on Xiith are made easier to make a better or basic understanding. Tutorials, testimonials, and examples are continuously checked to avoid delusion, but we cannot take complete responsibility of all programs on Xiith. When you are operating this site, you have to agree to read and accept our terms of use, cookie and privacy policy.Copyright © 2020 by Xiith. All Rights Reserved. About us.