Easy Tutorial
❮ C Examples Printf Double C Examples Sum Natural Numbers ❯

C Library Function - exp()

C Standard Library - <math.h>

Description

The C library function double exp(double x) returns the value of e raised to the power of x.

Declaration

Following is the declaration for the exp() function.

double exp(double x)

Parameters

Return Value

This function returns the value of e raised to the power of x.

Example

The following example demonstrates the usage of the exp() function.

#include <stdio.h>
#include <math.h>

int main ()
{
   double x = 0;

   printf("e raised to the power of %lf is %lf\n", x, exp(x));
   printf("e raised to the power of %lf is %lf\n", x+1, exp(x+1));
   printf("e raised to the power of %lf is %lf\n", x+2, exp(x+2));

   return(0);
}

Let's compile and run the above program, which will produce the following result:

e raised to the power of 0.000000 is 1.000000
e raised to the power of 1.000000 is 2.718282
e raised to the power of 2.000000 is 7.389056

C Standard Library - <math.h>

❮ C Examples Printf Double C Examples Sum Natural Numbers ❯