Latest web development tutorials

C library functions - log ()

C standard library - <math.h> C standard library - <math.h>

description

C library functionsdouble log (double x) Returns xnatural logarithm (base e logarithm of).

statement

Here is the statement log () function.

double log(double x)

parameter

  • x - floating-point value.

return value

This function returns the natural logarithm of x.

Examples

The following example illustrates the log () function is used.

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

int main ()
{
   double x, ret;
   x = 2.7;

   /* 计算 log(2.7) */
   ret = log(x);
   printf("log(%lf) = %lf", x, ret);
   
   return(0);
}

Let's compile and run the above program, which will result in the following:

log(2.700000) = 0.993252

C standard library - <math.h> C standard library - <math.h>