C log function calculates the natural logarithm for argument

Syntax

C log function has the following syntax.

  • float logf(float num);
  • double log(double num);
  • long double logl(long double num);

C log functions are from header file math.h.

Description

C log functions return the natural logarithm for num.

Example

The following code shows how to calculate the natural logarithm for argument by using C log function.


#include <math.h>
#include <stdio.h>
//from  www. ja  va 2 s .c  o  m
int main(void)
{
  double val = 1.0;

  do {
    printf("%f %f\n", val, log(val));
    val++;
  } while (val<11.0);

  return 0;
}

The code above generates the following result.





















Home »
  C Language »
    Function Reference »




assert.h
ctype.h
math.h
setjmp.h
signal.h
stdio.h
stdlib.h
string.h
time.h
wctype.h