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
Empty Interface Type in Go Programming Language
10 Countries Paying Highest Salaries to Cybersecurity Professionals
Go program to find PTR pointer record of a domain
Database as a Service (DBaaS): Simplifying Database Management in the Cloud
Cannot use <variable> as <type> value in return statement error in Golang
How to use WaitGroup to delay execution of the main function until after all goroutines are complete.
How do you read headers in an HTTP response in Go?
How to read names of all files and folders in current directory?
Golang program for implementation of Binary Search
Golang program for implementation of Floyd–Warshall Algorithm