C++ exp()
Published Jul 20, 2021Updated Dec 21, 2022
Contribute to Docs
The exp() function returns the base-e exponential value of the argument (i.e., e raised to the power of the argument). This is the inverse of the log() function.
Syntax
exp(x)
The x parameter is a double value that can be positive, negative, or zero.
Example
The following example uses the exp() function to find the value of e3:
#include <iostream>#include <cmath>int main() {double x = 3;double result;result = exp(x);std::cout << "The exp of " << x << " is " << result << "\n";}
This produces the following output:
The exp of 3 is 20.0855
Codebyte Example
The following example is runnable and returns the value of e1:
All contributors
Christine_Yang- garanews
borntofrappe
christian.dinh- Anonymous contributor
- StevenSwiniarski
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn C++ on Codecademy
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours
- Learn C++ — a versatile programming language that’s important for developing software, games, databases, and more.
- Beginner Friendly.11 hours