Ads by ProfitSence

C++ exp()

Last Updated on Wednesday 5th Oct 2022

exp math

The C++ exp() function returns the exponential (Euler's number) e raised to the given argument. It is defined in the <cmath> header file.

exp in math





The exp() function takes a one argument which can be any value i.e. negative, positive or zero.

Return value

Returns the value in the range of [0, ∞].

If the magnitude of the result is too large to be represented by a value of the return type, the function returns HUGE_VAL (or HUGE_VALF or HUGE_VALL) with the proper sign, and an overflow range error occurs.


exp() prototype [As of C++ 11 standard]

					double exp(double x);
float exp(float x);
long double exp(long double x);
double exp(T x); // For integral type


exponential in c

Example 1 : C++ exp()

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

int main () {
  double param, result;
  param = 5.0;
  result = exp (param);
  printf ("The exponential value of %f is %f.\n", param, result );
  return 0;



					The exponential value of 5.000000 is 148.413159.


c exp

Example 2 : C++ exp()

					#include <iostream>
#include <cmath>
using namespace std;

int main() {
    long int x = 4;
    double result;
    result = exp(x);
    cout << "exp(x) = " << result << endl;

    return 0;



					exp(x) = 54.5982