c中sqrt()函数为什么不能用

2025-06-23 03:15:49
推荐回答(2个)
回答1:

使用这个函数的时候需要引入math.h头文件

示例代码如下:

#include 
#include  /*引入math.h头文件*/

int main(int argc, char *argv[])
{
printf("%lf\n", sqrt(9)); /*使用sqrt函数*/
return 0;
}

运行结果如下:

回答2:

sqrt()函数是开方函数
要求()中的值为大于等于0的数
例如 sqrt(4)=±2