c語(yǔ)言求x的n次方的函數(shù)是什么
C語(yǔ)言 pow() 函數(shù)用來(lái)求 x 的 y 次方的值。
頭文件:math.h
語(yǔ)法/原型:
double pow(double x,double y);
參數(shù)說(shuō)明:
x:雙精度數(shù)。
y:雙精度數(shù)。
返回值:x 的 y 次方的值。
推薦學(xué)習(xí):c語(yǔ)言視頻教程
使用示例:
使用 pow() 函數(shù)求 4 的 6 次方,其代碼如下:
#include <stdio.h> #include <math.h> int main() { double x = 4, y = 6; //為變量賦初值 double result = pow(x, y); //求a的b次方 printf("%lfn", result); return 0; }
運(yùn)行結(jié)果:
4096.000000
php中文網(wǎng),大量編程入門(mén)教程,歡迎學(xué)習(xí)!