Exp in c – exp C Library Function

Exp in c: The function double exp(double x); returns the value of e raised to the power of x(ex).

Function prototype of exp

double exp(double x);
  • x : A floating point value representing the exponent of e.

Return value of exp

returns the value of e raised to the power of x (ex). If the value of the result is large enough to be represented by the return type, the function returns HUGE_VAL.

C program using exp function

The following program shows the use of exp function to calculate power of e.

exp C Library Function

#include <stdio.h>
#include <math.h>
 
int main(){
    double value, exponent;
    printf("Enter a number");
    scanf("%lf", &exponent);
     
    value = exp(exponent);
    printf("The value of e^%lf is %lf\n", exponent, value);
         
    return 0;
}

Output

Enter a number
0.5
The value of e^3.000000 is 20.085537