w3resource

C log10() function

C log10() function - Base 10 logarithm

Syntax:

double log10(double x)

The log10() function is used to calculate the base 10 logarithm of x.

Parameters:

Name Description Required /Optional
x Value whose logarithm is to be found. Required

Return value from log10()

  • Returns the computed value.

Example: log10() function

The following example calculates the base 10 logarithm of 100.0 and 1000.0.


#include <math.h>
#include <stdio.h>
 
int main(void)
{
   double x = 100.0, y; 
   y = log10(x); 
   printf("The base 10 logarithm of %lf is %lf\n", x, y);
   x = 1000.0; 
   y = log10(x); 
   printf("\nThe base 10 logarithm of %lf is %lf\n", x, y);
}
 

Output:

The base 10 logarithm of 100.000000 is 2.000000

The base 10 logarithm of 1000.000000 is 3.000000

C Programming Code Editor:

Previous C Programming: C log()
Next C Programming: C modf()



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/c-programming/math/c-log10.php