Home>Article>Backend Development> What is the code to open the root number in C language?

What is the code to open the root number in C language?

醉折花枝作酒筹
醉折花枝作酒筹 Original
2021-04-22 17:57:43 62713browse

In C language, the code to open the root sign is "sqrt (floating point value x)"; for example, "sqrt(4.0)" performs the square root operation on 4, and the result is 2. sqrt() is a built-in root operation function in C language. Its operation result is the arithmetic square root of the function variable; this function can neither operate negative values nor output imaginary results.

The operating environment of this tutorial: Windows 7 system, C 17 version, Dell G3 computer.

Add #include in the header file

Then use sqrt, you can use double definition

For example:

#include  #include  #include  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; }

What is the code to open the root number in C language?

Recommended tutorial: "C#"

The above is the detailed content of What is the code to open the root number in C language?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn