Home >>C Math Functions >C math log() function
C math log() function is used to return the natural logarithm (base-e logarithm) of an argument x. This takes a single argument and returns a value of type float. This function is defined in <math.h> header file.
Syntax:double log(double x)
x − It is the floating point value.
Here is an example of log() function:
#include <stdio.h>
#include <math.h>
int main ()
{
double x, ret;
x = 2.7;
ret = log(x);
printf("log(%lf) = %lf", x, ret);
return(0);
}
#include <stdio.h>
#include <math.h>
int main ()
{
double x, ret;
x = 10.5;
ret = log(x);
printf("log(%lf) = %lf", x, ret);
return(0);
}