This java code will give you output in a raise to power format. e.g. a raise to power b. 2 raise to power 3 is 8. As there is no pow() function in Java, you can use this method for implementing power functions.
Here's the code, compile as abc.java
Here's the code, compile as abc.java
public class abc
{
public static void main( String arg[]) {
int a,b,d=1,e,f;
a = Integer.parseInt(arg[0]);
b = Integer.parseInt(arg[1]);
d=a;
for(f=b;f>1;f--)
{
d = d*a;
}
System.out.print(d);
}
}
You can do a raise to power b raise to power c and so on... If you have any queries regarding this or any other java program please contact me. Thank you !
No comments:
Post a Comment