How to find the square root of a number using the scala programming language? In this program, we are using a built-in function for finding the square of any number.
object divinseo{
def main(args: Array[String]){
var num: Double = 0
var result: Double= 0
Console.println("Enter the number: ")
num=scala.io.StdIn.readInt()
result=scala.math.sqrt(num)
println("Result is : "+result)
}
}
Scala
Note: scala.math.sqrt(num)
is a built-in function that is used to find the square root of any number.
Output
Enter the number: 9
Result is : 3.0