In C++, the exp() function is defined in the <cmath> or <math.h> header file and is used to calculate the exponential value of a number. It computes the value of e raised to the power of the given number, where e is Euler’s number approximately equal to 2.71828.
The exp() function accepts integer, float, double, and long double values as input and returns the exponential result in the same floating-point type.
It has the following syntax.
x: The value whose exponential value is to be calculated.
It returns the exponential value of type float, double or long double.
If value is too large, the function returns HUGE_VAL
Here, we are going to discuss several examples to demonstrate the List exp() Function Function.
This example demonstrates how to calculate the exponential value when the input number is positive.
Output:
Value of x is : 0.2 Exponential value of x is : 1.2214
Explanation:
In this example, exp() function calculates the exponential value of x when the value of x is positive.
This example demonstrates how to calculate the exponential value when the input number is negative.
Output:
Value of x is : -5.3 Exponential value of x is : 0.00499159
Explanation:
In this example, exp() function calculates the exponential value of x when the value of x is negative.
This example demonstrates how to calculate the exponential value of zero using the exp() function. The value of exp(0) is always equal to 1.
Output:
Value of x is : 0
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India