The exp
function is part of the <math.h>
header file. It is equivalent to an exponent in mathematics. The function takes in a single parameter: a double
value. It then raises it to the power of e
and returns the resultant double
value.
exp(2) =
The illustration below shows how exp
works:
The exp
function is defined as follows:
double exp(double x);
It takes in a single parameter of type double
.
The following code snippet shows how we can use the exp
function. The code below outputs the exponent of the number in the parameter:
#include <stdio.h> // Including header file for printf function#include <math.h> // Including header file for exp functionint main(){double num = 5.0; // assign value to numberdouble result; // variable to store resultresult = exp(num); // taking exponent of numberprintf("The exponent of %.2lf is: %.2lf", num, result);return 0;}
Free Resources