What is exp in C?

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) = e2e^2

The illustration below shows how exp works:

How does exp work

Declaration

The exp function is defined as follows:

double exp(double x);

It takes in a single parameter of type double.

Example

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 function
int main(){
double num = 5.0; // assign value to number
double result; // variable to store result
result = exp(num); // taking exponent of number
printf("The exponent of %.2lf is: %.2lf", num, result);
return 0;
}

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved