exp()

exp() returns the base-e exponential function of the argument, which is e raised to the power of the argument.

The number e, also known as Euler’s number, is a mathematical constant approximately equal to 2.71828 and the base of the natural logarithm.

The cmath library must be added to the top of the file with #include <cmath>.

Syntax

Returns eⁿ:

std::exp(n)

Example

Use exp() to return the value of e³):

double result;
result = std::exp(3);

Codebyte Example

Use exp() to return the value of e (e¹):

Code
Output
Loading...

Contributors

Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.

Learn C++ on Codecademy