source file name:  mathdemo3.java

class mathdemo3

{

public static void main(String as[])

{

System.out.println("power values  of 2 base program ");

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

System.out.println(" 2 raised to "+b+" is: "+Math.pow(2,b));

}

}


output:


D:\JavaPrograms\Misc>javac mathdemo3.java

D:\JavaPrograms\Misc>java mathdemo3
power values  of 2 base program
 2 raised to 1 is: 2.0
 2 raised to 2 is: 4.0
 2 raised to 3 is: 8.0
 2 raised to 4 is: 16.0
 2 raised to 5 is: 32.0
 2 raised to 6 is: 64.0
 2 raised to 7 is: 128.0
 2 raised to 8 is: 256.0
 2 raised to 9 is: 512.0
 2 raised to 10 is: 1024.0