.Pow()
Published Feb 27, 2023Updated Apr 29, 2023
Contribute to Docs
The Math.Pow()
method returns a number raised to the power of a second number.
Syntax
Math.Pow(num1, num2)
Math.Pow()
takes two values of type double
. It will return a double
that is the result of the value num1
raised to the power of value num2
.
Example
The following example demonstrates the Math.Pow()
method and writes the result to the console.
using System;public class Example {public static void Main (string[] args) {double d1 = 8, d2 = 3;Console.WriteLine("8^3 = " + Math.Pow(d1,d2));}}
This example results in the following output:
8^3 = 512
Codebyte Example
The following example is runnable and uses the Math.Pow()
method to return a double
type value of 2
raised to the power of 10
:
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn C# on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Free course
Learn C#
Learn Microsoft's popular C# programming language, used to make websites, mobile apps, video games, VR, and more.Beginner Friendly23 hours