C Language: exp function(Exponential)

C Programming allows us to perform mathematical operations through the functions defined in header file. The header file contains various methods for performing mathematical operations such as sqrt(), pow(), ceil(), floor() etc.

C Math Functions

In the C Programming Language, the exp function returns e raised to the power of x.

Syntax

The syntax for the exp function in the C Language is




double exp(double x);



Parameters or Arguments

The value used in the calculation where e is raised to the power of x. If the magnitude of x is too large, the exp function will return a range error.

Returns

The exp function returns the result of e raised to the power of x.

Required Header

In the C Language, the required header for the exp function is:




#include <math.h>



Applies To

In the C Language, the exp function can be used in the following versions

  • ANSI/ISO 9899-1990

exp Example




/* Example using exp by c programming */

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

int main(int argc, const char * argv[])
{
    /* Define temporary variables */
    double value;
    double result;

    /* Assign the value we will find the exp of */
    value = 5;

    /* Calculate the exponential of the value */
    result = exp(value);

    /* Display the result of the calculation */
    printf("The Exponential of %f is %f\n", value, result);

    return 0;
}



When compiled and run, this application will output:

The Exponential of 2.100000 is 8.166170




Instagram