KnowledgeBoat Logo
LoginJOIN NOW

Computer Applications

Explain Java function Math.pow( ) with an example.

Input in Java

7 Likes

Answer

In Java, Math.pow( ) function returns the value of the first argument raised to the power of the second argument.

Syntax

<Return data type> <variable> = Function name (argument 1, argument 2);

double <variable> = Math.pow(arg1, arg2);

For example, consider the statement

double d = Math.pow(3, 2);

It will raise 3 to the power of 2 (3 * 3) and return a double type value for d as 9.0.

Answered By

5 Likes


Related Questions