Latest web development tutorials

C library functions - log10 ()

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

description

C library functionsdouble log10 (double x) Returns the common logarithm of x(base-10 logarithm).

statement

Here is () statement log10 function.

double log10(double x)

parameter

  • x - floating-point value.

return value

This function returns the common logarithm of x, the value of x is greater than 0.

Examples

The following example demonstrates log10 () function is used.

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

int main ()
{
   double x, ret;
   x = 10000;
  
   /* 计算 log10(10000) */
   ret = log10(x);
   printf("log10(%lf) = %lf\n", x, ret);
   
   return(0);
}

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

log10(10000.000000) = 4.000000

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