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()
// 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); } } |
Output:
36 42.875 1664966416
Reference: https://msdn.microsoft.com/en-us/library/system.math.pow(v=vs.110).aspx
Please Login to comment...