GO Program to Find the Largest Number Among Three Numbers
In this example, the largest number among three numbers (entered by the user) is found using if statement. An if statement consists of a Boolean expression followed by one or more statements.
Example
package main
import "fmt"
func main() {
fmt.Println("Enter 3 numbers :")
var first int
fmt.Scanln(&first)
var second int
fmt.Scanln(&second)
var third int
fmt.Scanln(&third)
/* check the boolean condition using if statement */
if (first>=second && first>=third) {
fmt.Println(first, "is Largest among three numbers.") /* if condition is true then print the following */
}
if (second>=first && second>=third){
fmt.Println(second, "is Largest among three numbers.")
}
if (third>=first && third>=second) {
fmt.Println(third, "is Largest among three numbers")
}
}
Most Helpful This Week
Example: ReadAll, ReadDir, and ReadFile from IO Package
Sierpinski Carpet in Go Programming Language
Pass an Interface as an argument to a function in Go (Golang)
How do you handle HTTP client server security in Go?
How do you set cookies in an HTTP request with an HTTP client in Go?
Golang program for implementation of Shell Sort