Home >Backend Development >C++ >How to type the root number in C language
In C language, use the sqrt() function to find the root. This function receives a floating point number and returns its square root. Correct usage: #include <math.h>, sqrt(double x);
## Find the root number in C language
In C language, you can use the following symbols to find the root:sqrt().
Usage:
sqrt() The function receives a floating-point number as a parameter and returns the square root of the number. Its syntax is as follows:
<code class="c">double sqrt(double x);</code>
Example:
The following code example demonstrates how to use thesqrt() function in C language:
<code class="c">#include <math.h> int main() { double x = 4.0; double y = sqrt(x); printf("x 的平方根为:%f\n", y); return 0; }</code>Output:
<code>x 的平方根为:2.000000</code>
Note:
Before using the <math.h>
header file.
The above is the detailed content of How to type the root number in C language. For more information, please follow other related articles on the PHP Chinese website!