Easy Tutorial
❮ C Function Strtoul C Function Strrchr ❯

C Library Function - log()

C Standard Library - <math.h>

Description

The C library function double log(double x) returns the natural logarithm (base e logarithm) of x.

Declaration

Here is the declaration for the log() function.

double log(double x)

Parameters

Return Value

This function returns the natural logarithm of x.

Example

The following example demonstrates the usage of the log() function.

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

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

   /* Calculate log(2.7) */
   ret = log(x);
   printf("log(%lf) = %lf", x, ret);

   return(0);
}

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

log(2.700000) = 0.993252

C Standard Library - <math.h>

❮ C Function Strtoul C Function Strrchr ❯