C 库函数 _ sqrt()

C 标准库 - <math.h> C 标准库 - <math.h>

描述

C 库函数 double sqrt(double x) 返回 x 的平方根。

声明

下面是 sqrt() 函数的声明。

double sqrt(double x)

参数

  • x -- 浮点值。

返回值

该函数返回 x 的平方根。

实例

下面的实例演示了 sqrt() 函数的用法。

#include <stdio.h>
#include <math.h>
int main ()
{
 printf("%lf 的平方根是 %lf\n", 4.0, sqrt(4.0) );
 printf("%lf 的平方根是 %lf\n", 5.0, sqrt(5.0) );
 
 return(0);
}

让我们编译并运行上面的程序,这将产生以下结果:

4.000000 的平方根是 2.000000
5.000000 的平方根是 2.236068

C 标准库 - <math.h> C 标准库 - <math.h>

0 个评论

要回复文章请先登录注册