Home »
Code Examples »
Scala Code Examples
Scala - Print the largest number among three numbers using the 'IF' statement Code Example
The code for Print the largest number among three numbers using the 'IF' statement
// Scala program to print largest number between
// two numbers using "IF" statement
object Sample{
def main(args:Array[String]){
var num1:Int = 0;
var num2:Int = 0;
print("Enter Number1: ")
num1=scala.io.StdIn.readInt()
print("Enter Number2: ")
num2=scala.io.StdIn.readInt()
if(num1>num2)
printf("%d is largest number\n",num1);
else
printf("%d is largest number\n",num2);
}
}
/*
Output:
Enter Number1: 23
Enter Number2: 15
23 is largest number
*/
Code by IncludeHelp,
on August 12, 2022 23:07