Home >>C Math Functions >C math exp() function

C math exp() function

C math exp() function

The C math double exp(double x) functionis used to return the value of e(exponential) raised to the xth power. It takes a single argument and returns the value in type double. This function is defined in <math.h> header file.

Syntax:
double exp( double arg );

Parameters:

x − It is the floating point value.

Here is an example of exp() function:

#include <stdio.h>
#include <math.h>
int main () {
double x = 0;
printf("The exponential value of %lf is %lf\n", x, exp(x));
printf("The exponential value of %lf is %lf\n", x+1, exp(x+1));
printf("The exponential value of %lf is %lf\n", x+2, exp(x+2));
return(0);
}

Output:
The exponential value of 0.000000 is 1.000000
The exponential value of 1.000000 is 2.718282
The exponential value of 2.000000 is 7.389056
Example-2

#include <stdio.h>
#include <math.h>
int main () {
double x = 10;
printf("The exponential value of %lf is %lf\n", x, exp(x));
printf("The exponential value of %lf is %lf\n", x+1, exp(x+1));
printf("The exponential value of %lf is %lf\n", x+2, exp(x+2));
return(0);
}

Output:
The exponential value of 10.000000 is 22026.465795
The exponential value of 11.000000 is 59874.141715
The exponential value of 12.000000 is 162754.791419