The log10() function defined in the math.h header file. It helps to return the base 10 logarithm of the given argument value.
double log10(double x); #where x should be in double
Also, two functions log10f() and log10l() were used with type float and long double respectively.
float log10f(float x);
long double log10l(long double x);
The log10() function takes a single parameter in double.
Parameter | Description | Required / Optional |
---|---|---|
x | whose base 10 logarithm needs to be found | Required |
The return value of log() function is a number in float.
Input | Return Value |
---|---|
x > 0 | Finds the log10 of the argument |
x < 0 | Shows run-time error |
#include <stdio.h>
#include <math.h>
int main()
{
double N = 4.00, output;
output = log10(N);
printf("The value of log10(%.1f) is %.2f", N, output);
return 0;
}
Output:
The value of log10(4.0) is 0.60
#include <stdio.h>
#include <math.h>
int main () {
double k, out;
k = 10000;
out = log10(k);
printf("The value of log10(%lf) is %lf", k, out);
return(0);
}
Output:
The value of log10(10000.000000) = 4.000000