c語言求x的n次方的函數(shù)是什么
C語言 pow() 函數(shù)用來求 x 的 y 次方的值。
頭文件:math.h
語法/原型:
double pow(double x,double y);
參數(shù)說明:
x:雙精度數(shù)。
y:雙精度數(shù)。
返回值:x 的 y 次方的值。
推薦學(xué)習(xí):c語言視頻教程
使用示例:
使用 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),大量編程入門教程,歡迎學(xué)習(xí)!