在c语言中log怎么输入?

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/19 05:24:29
在c语言中log怎么输入?

在c语言中log怎么输入?
在c语言中log怎么输入?

在c语言中log怎么输入?
原型:double log (double x);   
头文件:math.h   
功能:计算以e 为底的对数值   
程序例:   
#include   
#include   
int main(void) 
{ 
double result;   
double x = 321.123;   
result = log(x);   
printf("The common log of %lf is %lf\n", x, result);   
return 0;   
}
C语言里面有该函数,所以输入一个双精度浮点数,对其进行函数变换即可生成其对数.
还有如果你的意思是输入对数进行幂运算的话有下面这个函数
原型:extern float pow(float x, float y);
用法:#include
功能:计算x的y次幂.
说明:x应大于零,返回幂指数的结果.
举例:
// pow.c
#include
#include
#include
void main()
{
printf("4^5=%f",pow(4.,5.));
getchar();
}