log() function in C++

The C/C++ library function double log(double x) returns the natural logarithm (basee logarithm) of x. Following is the declaration for log() function.

double log(double x)

The parameter is a floating point value. And this function returns natural logarithm of x.


 Live Demo

#include <iostream>
#include <cmath>
using namespace std;
int main () {
   double x, ret;
   x = 2.7;
   /* finding log(2.7) */
   ret = log(x);
   cout << "log("<< x <<") = " << ret;


log(2.7) = 0.993252