Latest web development tutorials

C 庫函數– exp()

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

描述

C庫函數double exp(double x)返回ex次冪的值。

聲明

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

double exp(double x)

參數

  • x --浮點值。

返回值

該函數返回e 的x 次冪。

實例

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

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

int main ()
{
   double x = 0;
  
   printf("e 的 %lf 次幂是 %lf\n", x, exp(x));
   printf("e 的 %lf 次幂是 %lf\n", x+1, exp(x+1));
   printf("e 的 %lf 次幂是 %lf\n", x+2, exp(x+2));
   
   return(0);
}

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

e 的 0.000000 次幂是 1.000000
e 的 1.000000 次幂是 2.718282
e 的 2.000000 次幂是 7.389056

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