Introduction
Returns the square root of the argument in Java.square root:
a number that produces a specified quantity when multiplied by itself.
7 is a square root of 49
double sqrt(double d)
Sample Code
public class main {
public static void main (String [] args) {
//Returns the square root of the argument.
System.out.println("Math.sqrt(100) = " + Math.sqrt(100));
System.out.println("Math.sqrt(81) = " + Math.sqrt(81));
System.out.println("Math.sqrt(64) = " + Math.sqrt(64));
System.out.println("Math.sqrt(49) = " + Math.sqrt(49));
System.out.println("Math.sqrt(36) = " + Math.sqrt(36));
System.out.println("Math.sqrt(25) = " + Math.sqrt(25));
System.out.println("Math.sqrt(16) = " + Math.sqrt(16));
System.out.println("Math.sqrt(9) = " + Math.sqrt(9));
System.out.println("Math.sqrt(4) = " + Math.sqrt(4));
System.out.println("Math.sqrt(1) = " + Math.sqrt(1));
System.out.println("Math.sqrt(0) = " + Math.sqrt(0));
}
}
Output from The Program
Math.sqrt(100) = 10.0
Math.sqrt(81) = 9.0
Math.sqrt(64) = 8.0
Math.sqrt(49) = 7.0
Math.sqrt(36) = 6.0
Math.sqrt(25) = 5.0
Math.sqrt(16) = 4.0
Math.sqrt(9) = 3.0
Math.sqrt(4) = 2.0
Math.sqrt(1) = 1.0
Math.sqrt(0) = 0.0
Java Tutorial Beyond Basic Arithmetic
0 留言