English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
C ++in the exp() function
This function calculates and returns e raised to the power of x<cmath>defined in the header file.
ex = exp(x)
double exp(double x); float exp(float x); long double exp(long double x); double exp(T x); //For integer
The exp() function has only one parameter and returns an exponent value of type double, float, or long double.
The exp() function takes a mandatory parameter and can be any value, i.e., negative, positive, or zero.
The exp() function returns values in the range [0, ∞].
If the size of the result is too large to be represented by the return type value, the function will return HUGE_VAL with the correct sign and an overflow range error will occur.
#include <iostream> #include <cmath> using namespace std; int main() { double x = 2.19, result; result = exp(x); cout << "exp(x) = " << result << endl; return 0; }
The output when running the program is:
exp(x) = 8.93521
#include <iostream> #include <cmath> using namespace std; int main() { long int x = 13; double result; result = exp(x); cout << "exp(x) = " << result << endl; return 0; }
The output when running the program is:
exp(x) = 442413