In C, the root sign can be calculated through the sqrt() function, which accepts floating-point number parameters and returns its square root: Function call syntax: double sqrt(double x); Parameters: The floating-point number x to calculate the square root; Return value: The square root of x if x is nonnegative; otherwise NaN (not a number).
The root number in C
In C, you can use sqrt()
Function calculates the root. This function accepts a floating point number as argument and returns its square root.
Use sqrt()
Function
Syntax:
<code class="cpp">double sqrt(double x);</code>
Parameters:
x
: The floating point number to calculate the square root Return value: The square root of
x
, if x
is not Negative number; otherwise returns NaN
(not a number) Example:
<code class="cpp">#include <iostream> #include <cmath> int main() { double number = 9.0; double square_root = sqrt(number); std::cout << "平方根为:" << square_root << std::endl; return 0; }</code>
Output:
<code>平方根为:3</code>
The above is the detailed content of How to type the root number in c++. For more information, please follow other related articles on the PHP Chinese website!