溫馨提示×

C語言中power函數的用法是什么

小億
546
2023-10-11 20:29:11
欄目: 編程語言

在C語言中,power函數用于計算一個數的冪。

函數原型為:

double pow(double x, double y);

參數x是底數,參數y是指數。函數返回x的y次方的結果。

示例代碼:

#include <stdio.h>
#include <math.h>
int main() {
double base = 2.0;
double exponent = 3.0;
double result = pow(base, exponent);
printf("%f raised to the power of %f is %f\n", base, exponent, result);
return 0;
}

輸出結果:

2.000000 raised to the power of 3.000000 is 8.000000

在上面的示例中,pow函數計算了2的3次方,得到了8的結果。

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女