source file name:  mathdemo2.java

class mathdemo2

{

public static void main(String as[])

{

System.out.println("square root program");

for(int b=1;b<=10;b++)

System.out.println("square root of "+b+" is: "+Math.sqrt(b));

}

}

output:

D:\JavaPrograms\Misc>javac mathdemo2.java

D:\JavaPrograms\Misc>java mathdemo2
square root program
square root of 1 is: 1.0
square root of 2 is: 1.4142135623730951
square root of 3 is: 1.7320508075688772
square root of 4 is: 2.0
square root of 5 is: 2.23606797749979
square root of 6 is: 2.449489742783178
square root of 7 is: 2.6457513110645907
square root of 8 is: 2.8284271247461903
square root of 9 is: 3.0
square root of 10 is: 3.1622776601683795