Find the output of :System.out.print(Math.Pow(9,1/2 ));
Answers
Answer:
Java Math.pow() method
The java.lang.Math.pow() is used to return the value of first argument raised to the power of the second argument. The return type of pow() method is double.
Syntax
public static double pow(double a, double b)
Parameter
a= base
b= exponent
Return
This method returns the value of ab
If the second argument is positive or negative Zero, this method will return 1.0.
If the second argument is not a number (NaN), this method will return NaN.
If the second argument is 1, this method will return the result same as the first argument.
Example 1
public class PowExample1
{
public static void main(String[] args)
{
double x = 5;
double y = 4;
//returns 5 power of 4 i.e. 5*5*5*5
System.out.println(Math.pow(x, y));
}
}
Test it Now
Output:
625.0
Example 2
public class PowExample2
{
public static void main(String[] args)
{
double x = 9.0;
double y = -3;
//return (9) power of -3
System.out.println(Math.pow(x, y));
}
}
Test it Now
Output:
0.0013717421124828531
Example 3
public class PowExample3
{
public static void main(String[] args)
{
double x = -765;
double y = 0.7;
//return NaN
System.out.println(Math.pow(x, y));
}
}
Test it Now
Output:
NaN
Example 4
public class PowExample4
{
public static void main(String[] args)
{
double x = 27.2;
double y = 1.0;
// Second argument is 1 so output is 27.2
System.out.println(Math.pow(x, y));
}
}
Test it Now
Output:
3.5461138422596736
← prevnext →
Help Others, Please Share
facebook twitter pinterest
Learn Latest Tutorials
Proc*C
Proc*C
social media marketing
SMM
GDB
GDB
Fuzzy Logic
Fuzzy Logic
DHTML
DHTML
Google Classroom
Classroom
autocad Tutorial
AutoCad
kubernetes Tutorial
Kubernetes
Openpyxl Tutorial
Openpyxl
Tally Tutorial
Tally
Godot Tutorial
Godot
Spring Boot Tutorial
Spring Boot
Preparation
Aptitude
Aptitude
Logical Reasoning
Reasoning
Verbal Ability
Verbal A.