C# | Math.Pow() Method

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()

filter_none

edit
close

play_arrow

link
brightness_4
code

// C# program to illustrate the 
// Math.Pow() function
using System;
class GFG {
  
    // Main Method
    static public void Main()
    {
  
        // Find power using Math.Pow
        // 6 is base and 2 is power or
        // index or exponent of a number
        double pow_ab = Math.Pow(6, 2);
  
        // Print the result
        Console.WriteLine(pow_ab);
  
        // 3.5 is base and 3 is power or
        // index or exponent of a number
        double pow_tt = Math.Pow(3.5, 3);
  
        // Print the result
        Console.WriteLine(pow_tt);
  
        // 202 is base and 4 is power or
        // index or exponent of a number
        double pow_t = Math.Pow(202, 4);
  
        // Print the result
        Console.WriteLine(pow_t);
    }
}

chevron_right


Output:

36
42.875
1664966416

Reference: https://msdn.microsoft.com/en-us/library/system.math.pow(v=vs.110).aspx



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.