The ** Math.Pow()** function returns the

`base`

to the `exponent`

power, that is, `base`^{exponent}

.The Math.Pow method is used to calculate the exponent value of a number. The method takes two parameters. The first parameter is the base and the second parameter is the force. Method can used for all number types. After calculating the pow method **returns double** type

if you enter the second number negative, the method calculate fractional exponentiation. ** Ex: Math.Pow(2,-2) =1/(2 ^{2}) = 0,25**

In this tutorial, we will learn how to take input from user and and display output in C# using various methods

**Usage:**

1 2 3 |
double returnNumber = Math.Pow(baseNumber, powerNumber); |

**Example:**

1 2 3 4 5 6 7 8 9 10 11 12 13 |
double baseNumber, powerNumber; Console.Write("Enter base number :"); baseNumber = Convert.ToDouble(Console.ReadLine()); Console.Write("Enter exponent number :"); powerNumber = Convert.ToDouble(Console.ReadLine()); double returnNumber = Math.Pow(baseNumber, powerNumber); Console.WriteLine("{0}^{1} = {2}", baseNumber, powerNumber, returnNumber); Console.ReadLine(); |

**Output:**

### C# Math.Pow Negative Exponent Example

1 2 3 4 5 6 7 8 9 10 11 12 13 |
double baseNumber, powerNumber; Console.Write("Enter base number :"); baseNumber = Convert.ToDouble(Console.ReadLine()); //2 Console.Write("Enter exponent number :"); powerNumber = Convert.ToDouble(Console.ReadLine()); //-2 double returnNumber = Math.Pow(baseNumber, powerNumber); Console.WriteLine("{0}^{1} = {2}", baseNumber, powerNumber, returnNumber); Console.ReadLine(); |

**Output:**

### C# Math.Pow Form Example:

**Output:**

**Code:**

1 2 3 4 5 6 7 8 9 |
private void btnCalculate_Click(object sender, EventArgs e) { double baseNumber = Convert.ToDouble(txtBase.Text); double exponentNumber = Convert.ToDouble(txtExponent.Text); double result = Math.Pow(baseNumber, exponentNumber); lbResult.Text = result.ToString(); } |