天天看點

C 庫函數 - exp()

C 标準庫 - <math.h>

描述

C 庫函數

double exp(double x)

傳回

e

x

次幂的值。

聲明

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

double exp(double 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