MathF.Pow() Method in C# with Examples


The MathF.Pow() method in C# is used to compute a number raise to the power of another number.

Syntax

Following is the syntax −

public static float Pow (float val1, float val2);

Above, val1 is the floating-point number raised to a power. The val2 parameter is the power or exponent.

Example

Let us now see an example to implement the MathF.Pow() method −

using System;
public class Demo {
   public static void Main(){
      float val1 = 5.00f;
      float val2 = 3.00f;
      Console.WriteLine("MathF.Pow() = "+MathF.Pow(val1, val2));
   }
}

Output

This will produce the following output −

MathF.Pow() = 125

Example

Let us now see another example to implement the MathF.Pow() method −

using System;
public class Demo {
   public static void Main(){
      float val1 = 15.20f;
      float val2 = 3.10f;
      Console.WriteLine("MathF.Pow() = "+MathF.Pow(val1, val2));
   }
}

Output

This will produce the following output −

MathF.Pow() = 4610.149

Updated on: 13-Nov-2019

129 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements