exp() function C++


The C / C++ library function double exp(double x) returns the value of e raised to the xth power. Following is the declaration for exp() function.

double exp(double x)

The parameter is a floating point value. And this function returns the exponential value of x.

Example

 Live Demo

#include <iostream>
#include <cmath>
using namespace std;
int main () {
   double x = 0;
   cout << "The exponential value of " << x << " is " << exp(x) << endl;
   cout << "The exponential value of " << x+1 << " is " << exp(x+1) <<
   endl;
      cout << "The exponential value of " << x+2 << " is " << exp(x+2) <<
   endl;
   return(0);
}

Output

The exponential value of 0 is 1
The exponential value of 1 is 2.71828
The exponential value of 2 is 7.38906

Updated on: 30-Jul-2019

562 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements