# Scala program to find the largest number between two numbers

In this post, we are going to see how you can find the largest number between two numbers. This program can be made by using so many ways. We are going to 3-4 possible ways to make this program.

## find the largest number between two numbers using the ternary operator

``````object divineseo{
def main(args:Array[String]){
var num1: Int =0
var num2: Int =0
var large: Int =0

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

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

large=if(num1>num2)num1 else num2

println("Largest Number is :" +large)
}
}``````
Scala

Output

``````Enter 1st  Number: 12
Enter 2nd Number: 45
Largest Number is :45``````

Note: Use Stdin to take the number as input from the user.

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

``````object divineseo{
def main(args:Array[String]){
var num1: Int =0
var num2: Int =0

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

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

if(num1>num2)
println("Largest number is :" +num1)
else
println("Largest number is :" +num2)
}
}``````
Scala

Output

``````Enter 1st  Number: 23
Enter 2nd Number: 47
Largest number is :47``````

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

``````object divineseo{
def main(args:Array[String]){
var num1: Int =0
var num2: Int =0

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

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

if(num1 > num2)
println("Largest number is :" +num1)
else if(num2 > num1)
println("Largest number is :" +num2)
else
println("Both Numbers Are Equal")
}
}``````
Scala

Output

``````Enter 1st  Number: 90
Enter 2nd Number: 90
Both Numbers Are Equal``````