15. Pow(x,n)
Implement the power function pow(x, n) , which calculates the x raised to n i.e. xn.
Note : In output print 6 digits places after decimal point.
Example 1:
Input : x = 2.0000 , n = 10
Output : 1024.0000
Explanation : Answer = 2^10 => 1024.
Example 2:
Input : x = 2.0000 , n = -2
Output : 0.2500
Explanation : Answer = 2^(-2) = 1/4 => 0.25.
Now Your Turn!
Pick the correct output for the given inputInput : x = 2.5000 , n = 2
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- -100.0 <= x <= 100.0
- -231 <= n <= 231 - 1
- -104 <= xn <= 104
- Either x is not zero or n>0.
- n is an integer.