c语言开根号代码是什么

CTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> coding="utf-8" ?>ckquote>

C语言中,开根号的代码是“sqrt(浮点值x)”;例如“sqrt(4.0)”,对4进行平方根运算,结果为2。sqrt()是c语言内置的开根号运算函数,其运算结果是函数变量的算术平方根;该函数既不能运算负数值,也不能输出虚数结果。

ckquote>

[[IMG_PLACEHOLDER_0]]

本教程操作环境:windows7系统、C++17版本、Dell G3电脑。

在头文件中加入#include

之后使用sqrt即可,可以用double定义

举个例子:

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
double sqrt(double n);
int main(void)
{
double x = 3.1415926540, result;
result = sqrt(x);
printf("The square root of %lf is %lf", x, result);
return 0;
}

[[IMG_PLACEHOLDER_1]]

推荐教程:《C#》

以上就是c语言开根号代码是什么的详细内容,更多请关注www.sxiaw.com其它相关文章!