C log10 函数

C log10 函数是用于计算以 10 为底的数字的对数值的数学函数之一。数学 log10 函数的语法是

double log10(double number);

log10 函数示例

math log10 函数允许您找到以 10 为底的对数值。此程序将查找 log10 值并显示输出。

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

int main()
{
    printf("\n The Logarithmic Value of 0 base 10      = %.4f ", log10(0));
    printf("\n The Logarithmic Value of 1 base 10      = %.4f ", log10(1));
    
    printf("\n The Logarithmic Value of 15 base 10     = %.4f ", log10(15));
    printf("\n The Logarithmic Value of 29.3 base 10   = %.4f ", log10(29.3));
    
    printf("\n The Logarithmic Value of -6.32 base 10  = %.4f ", log10(-6.32));  
    printf("\n The Logarithmic Value of -14.4 base 10  = %.4f ", log10(-14.4));
  
    return 0;
}
C log10 Function to find the base 10 logarithmic value

log10 示例 2

在此 C Programming 示例中,我们允许用户输入自己的值。接下来,程序使用 math log10 函数来查找用户给定数字以 10 为底的对数值。

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

int main()
{
    float number, logValue;

    printf(" Please Enter any Numeric Value :  ");
    scanf("%f", &number);
  
    logValue = log10(number);
  
    printf("\n Logarithmic Value of %.2f base 10 = %.4f ", number, logValue);
  
    return 0;
}
 Please Enter any Numeric Value :  98.567

 Logarithmic Value of 98.57 base 10 = 1.9937