C语言:求x的y次方的值(pow()函数)

pow语法:

double pow(double x,double y);

例:求 2 的 5次方,其代码如下:

 
 
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main() {
  5. double x = 2, y = 5; //为x,y变量(双精度数)赋初值
  6. double result = pow(x, y); //求x的y次方
  7. printf("%lf\n", result);
  8.  
  9. return 0;
  10. }

运行结果:
32.000000

猜你喜欢

转载自blog.csdn.net/weixin_44015669/article/details/92655160