Java Program To Find Power Of Number Using pow() Function
Chapter:
Math Class
Last Updated:
29-08-2017 15:40:32 UTC
Program:
/* ............... START ............... */
public class JavaPowerOfNumberUsingPowFunction {
public static void main(String[] args) {
int base = 2, exponent = 3;
double result = Math.pow(base, exponent);
System.out.println("Answer = " + result);
}
}
/* ............... END ............... */
Output
Notes:
-
In the above program we use Math.pow() function to calculate the power of the given base.
- Math.pow() returns the value of the first argument raised to the power of the second argument.
- Syntax : double pow(double base, double exponent)
- base − Any primitive data type.
- exponenet − Any primitive data type.
Tags
Find Power Of Number Using pow() Function, Java, Math