C++ exp() 函式


C/C++ 庫函式 double exp(double x) 返回以 x 為次方的 e 的值。以下是 exp() 函式的宣告。

double exp(double x)

引數是浮點值。此函式返回 x 的指數值。

示例

 即時演示

#include <iostream>
#include <cmath>
using namespace std;
int main () {
   double x = 0;
   cout << "The exponential value of " << x << " is " << exp(x) << endl;
   cout << "The exponential value of " << x+1 << " is " << exp(x+1) <<
   endl;
      cout << "The exponential value of " << x+2 << " is " << exp(x+2) <<
   endl;
   return(0);
}

輸出

The exponential value of 0 is 1
The exponential value of 1 is 2.71828
The exponential value of 2 is 7.38906

更新時間:30-Jul-2019

626 人次檢視

啟動你的職業

透過完成課程獲得認證

開始學習
廣告
© . All rights reserved.