Scala Program to Calculate the Cube Root of a Given Number Using Scala.math.cbrt() Function

You are currently viewing Scala Program to Calculate the Cube Root of a Given Number Using Scala.math.cbrt() Function

Scala program to calculate the cube root of a given number using scala.math.cbrt() function

// Scala program to calculate the cube root 
// of a given number

object Sample{  
    def main(args:Array[String]){  
        var num:Double    = 0;
        var res:Double = 0;
           
        print("Enter number: ")
        num=scala.io.StdIn.readDouble()

        res= scala.math.cbrt(num)
        println("result: "+res);
    }  
}
Enter number: 27
result: 3.0

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply