Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Go Programs
    • Python Programs
    • Java Programs

Go Program to find Largest of Three Numbers

by suresh

This Go Program to find the Largest of Three Numbers uses the Else If statement. Within the Else if, we used the logical and operator to separate two conditions.

  • a > b && a > c – Check whether a is greater than b and c. If True, a is largest.
  • else if b > a && b > c – Check b is greater than a and c. If True, b is largest.
  • else if c > a && c > b – Check c is greater than a and b. If True, c is largest. Otherwise, either of them is equal.
package main

import "fmt"

func main() {

    var a, b, c int

    fmt.Print("\nEnter the Three Numbers to find Largest = ")
    fmt.Scanln(&a, &b, &c)

    if a > b && a > c {
        fmt.Println(a, " is Greater Than ", b, " and ", c)
    } else if b > a && b > c {
        fmt.Println(b, " is Greater Than ", a, " and ", c)
    } else if c > a && c > b {
        fmt.Println(c, " is Greater Than ", a, " and ", b)
    } else {
        fmt.Println("Either of them are Equal ")
    }
}
Go Program to find Largest of Three Numbers 1

Go Program to find Largest of Three Numbers.

This Golang program uses the arithmetic operator and logical operator to print the Largest of Three Numbers.

package main

import "fmt"

func main() {

    var a, b, c int

    fmt.Print("\nEnter the Three Numbers to find Largest = ")
    fmt.Scanln(&a, &b, &c)

    if a-b > 0 && a-c > 0 {
        fmt.Println(a, " is Greater Than ", b, " and ", c)
    } else {
        if b-c > 0 {
            fmt.Println(b, " is Greater Than ", a, " and ", c)
        } else {
            fmt.Println(c, " is Greater Than ", a, " and ", b)
        }
    }
}
Golang Program to find Largest of Three Numbers 2

Placed Under: Go Examples

  • Golang Hello World Program
  • Go Add Two Number
  • Go Compound Interest
  • Go Count Digits in a Number
  • Go Cube of a Number
  • Go Even or Odd
  • Go Largest of Three Numbers
  • Go Reverse Natural Numbers
  • Go Multiplication Table
  • Go Number divisible by 5 and 11
  • Go Positive or Negative
  • Go Power of a Number
  • Go Print Natural Numbers
  • Go Profit or Loss
  • Go Print 1 to 100 without loop
  • Go Program to Print 1 to 100
  • Go Product of Digits in a Number
  • Go Palindrome Number Program
  • Go Print Even Numbers
  • Go Print Odd Numbers
  • Go Factors of a Number
  • Go Perfect Number
  • Go Prime Number
  • Go Reverse a Number
  • Go Simple Interest
  • Go Square of a Number
  • Go Square root of a Number
  • Go Sum of Digits in a Number
  • Go Sum & Avg of Natural Nums
  • Go Sum of Even Numbers
  • Go Sum of Odd Numbers
  • Go Sum of Even and Odd
  • Go Sphere Vol & Surface Area
  • Go Cylinder Vol & Surface Area
  • Go Cuboid Vol & Surface Area
  • Go Cube Volume & Surface Area
  • Go Cone Volume & Surface Area

Copyright © 2021 · All Rights Reserved by Suresh

About Us | Contact Us | Privacy Policy