Home >Backend Development >C#.Net Tutorial >How to express the nth power of a in C language
In C language, the pow() function is used to calculate the nth power of a. The base a needs to be used as base and the exponent n needs to be passed to the function as exponent. For example, to calculate 2 raised to the 5th power, call pow(2, 5).
The nth power of a in C language
In C language, use the pow() function to calculate a to the nth power. The prototype of this function is:
<code class="c">double pow(double base, double exponent);</code>
where:
To calculate a To the power n, you simply pass a as the base and n as the exponent to the pow() function. For example:
<code class="c">#include <stdio.h> #include <math.h> int main() { // 计算 2 的 5 次方 double result = pow(2, 5); // 输出结果 printf("2 的 5 次方是 %f\n", result); return 0; }</code>
Output:
<code>2 的 5 次方是 32.000000</code>
Note:
The above is the detailed content of How to express the nth power of a in C language. For more information, please follow other related articles on the PHP Chinese website!