Latest web development tutorials

C 庫函數– pow()

C 標準庫 - <math.h> C標準庫- <math.h>

描述

C庫函數double pow(double x, double y)返回xy次冪,即x y

聲明

下面是pow() 函數的聲明。

double pow(double x, double y)

參數

  • x --代表基數的浮點值。
  • y --代表指數的浮點值。

返回值

該函數返回x 的y 次冪的結果。

實例

下面的實例演示了pow() 函數的用法。

#include <stdio.h>
#include <math.h>

int main ()
{
   printf("值 8.0 ^ 3 = %lf\n", pow(8.0, 3));

   printf("值 3.05 ^ 1.98 = %lf", pow(3.05, 1.98));
   
   return(0);
}

讓我們編譯並運行上面的程序,這將產生以下結果:

值 8.0 ^ 3 = 512.000000
值 3.05 ^ 1.98 = 9.097324

C 標準庫 - <math.h> C標準庫- <math.h>