C <math.h> - exp() Function
The C <math.h> exp() function returns e raised to the power of specified number, i.e., ex. Please note that e is the base of the natural system of logarithms, and its value is approximately 2.718282.
Syntax
double exp (double x); float expf (float x); long double expl (long double x);
Parameters
x |
Specify the exponent of e. |
Return Value
Returns e raised to the power of specified number.
Example:
In the example below, exp() function is used to calculate e raised to the power of specified number.
#include <stdio.h> #include <math.h> int main (){ printf("%lf\n", exp(2)); printf("%lf\n", exp(-2)); printf("%lf\n", exp(1.5)); printf("%lf\n", exp(-1.5)); return 0; }
The output of the above code will be:
7.389056 0.135335 4.481689 0.223130
❮ C <math.h> Library