log() function in C++

C++Server Side ProgrammingProgramming

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.

Example

 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;
   return(0);
}

Output

log(2.7) = 0.993252
raja
Published on 02-Apr-2019 10:24:26

Advertisements