How to find the Minimum of Three Numbers in Go - Step by Step Examples
How to find the Minimum of Three Numbers in Go ?
Answer
To find the minimum of three numbers in Go, you can use a simple comparison with if statements.
✐ Examples
1 Find Minimum of Three Numbers
In this example,
- We declare three variables
a
,b
, andc
with the numbers to compare. - We use a series of if statements to compare the numbers and update the minimum accordingly.
Go Program
package main
import "fmt"
func main() {
a := 5
b := 8
c := 3
min := a
if b < min {
min = b
}
if c < min {
min = c
}
fmt.Println("Minimum of three numbers is:", min)
}
Output
Minimum of three numbers is: 3
Summary
In this tutorial, we learned How to find the Minimum of Three Numbers in Go language with well detailed examples.