In C#, Math.Pow() is a Math class method. This method is used to calculate a number raise to the power of some other number.
Syntax:
public static double Pow(double base, double power)
Parameters:
double base: It is a double-precision floating-point number which is to be raised to a power and type of this parameter is System.Double.
double power: It is a double-precision floating-point number which specifies a power or exponent and type of this parameter is System.Double.
Return Type: The function returns the number base raised to the power. The type of this method is System.Double
Examples:
Input : base = 8, power =2
Output : 64
Input : base = 2.5, power =3
Output : 15.625
Program: To demonstrate the Math.Pow()
using System;
class GFG {
static public void Main()
{
double pow_ab = Math.Pow(6, 2);
Console.WriteLine(pow_ab);
double pow_tt = Math.Pow(3.5, 3);
Console.WriteLine(pow_tt);
double pow_t = Math.Pow(202, 4);
Console.WriteLine(pow_t);
}
}
|
Output:
36
42.875
1664966416
Reference: https://msdn.microsoft.com/en-us/library/system.math.pow(v=vs.110).aspx