# Scala program to find the largest number among three numbers

In this post, we are going to see how you can find the largest number among three numbers. This program can be made by using so many ways. We are going to learn about 2 possible ways to make this program. The first method is by using the ternary operator, the second is if else and the last one will be the else if condition.

## find the largest number among three numbers using the ternary operator

``````object divineseo{
def main(args: Array[String]){
var n1: Int = 0
var n2: Int = 0
var n3: Int=  0
var result: Int = 0

Console.println("Enter 1st number: ")

Console.println("Enter 2nd number: ")

Console.println("Enter 3rd number: ")

result = if(n1>n2 && n1>n3) n1 else if (n2>n1 && n2>n3) n2 else n3

println("The largest number is :" +result)
}
}``````
Scala

Output

``````Enter 1st number: 23
Enter 2nd number: 90
Enter 3rd number: 101
The largest number is :101``````

## find the largest number between two numbers using the If Else Condition

``````object divineseo{
def main(args: Array[String]){
var n1: Int = 0
var n2: Int = 0
var n3: Int=  0
var result: Int = 0

Console.println("Enter 1st number: ")

Console.println("Enter 2nd number: ")

Console.println("Enter 3rd number: ")

if(n1>n2 && n1>n3)
println("Largest number is :" +n1)
else if (n2>n1 && n2>n3)
println("Largest number is :" +n2)
else if(n3>n1 && n3>n2)
println("Largest number is :" +n3)
else
println("Entered numbers are equal!!!")
}
}``````
Scala

Output

``````Enter 1st number: 100
Enter 2nd number: 23
Enter 3rd number: 567
Largest number is :567``````