C Programming Tutorial
C Programming allows us to perform mathematical operations through the functions defined in
C Math Functions
In the C Programming Language, the log10 function returns the logarithm of x to the base of 10.
Syntax
The syntax for the log10 function in the C Language is:
double log10(double x);
Parameters or Arguments
A value used in the calculation of the logarithm of x to the base of 10. If x is negative, the log10 function will return a domain error. If x is zero, the log10 function will return a range error.
Returns
The log10 function returns the logarithm of x to the base of 10.
Required Header
In the C Language, the required header for the log10 function is:
#include <math.h>
Applies To
In the C Language, the log10 function can be used in the following versions:
- ANSI/ISO 9899-1990
log10 Example
/* Example using log10 by c programming */ #include <stdio.h> #include <math.h> int main(int argc, const char * argv[]) { /* Define temporary variables */ double value; double result; /* Assign the value we will calculate the log10 of */ value = 1.5; /* Calculate the log10 of the value */ result = log10(value); /* Display the result of the calculation */ printf("The Base 10 Logarithm of %f is %f\n", value, result); return 0; }
When compiled and run, this application will output:
The Base 10 Logarithm of 1.500000 is 0.176091