C语言中,有两个log函数,分别为log10和log(x)函数,具体用法如下:
函数名: log10
功 能:
对数函数log,以10为底
用 法: double log10(double x);
程序示例:
#include <math.h>
#include <stdio.h>int main(void)
{
double result;
double x = 800.6872;
result = log10(x);
printf("The common log of %lf is %lf\n", x, result);
return 0;
}
函数名: log
功 能: 对数函数log,以e为底,相当于lnx
用 法: double log(double x);
程序示例:
#include <math.h>
#include <stdio.h>int main(void)
{
double result;
double x = 800.6872;
result = log(x);
printf("The common log of %lf is %lf\n", x, result);
return 0;
}
loga^b = lnb / lna= logb / loga
程序代码:
1:
#include <stdio.h>
#include<math.h>
int main ()
{
float d,p,r,m;
d=300000;
p=6000;
r=0.01;