function
<cmath> <ctgmath>

# sqrt

```double sqrt (double x);
```
```     double sqrt  (double x);
float sqrtf (float x);
long double sqrtl (long double x);
```
```     double sqrt (double x);
float sqrt (float x);
long double sqrt (long double x);
```
```     double sqrt (double x);
float sqrt (float x);
long double sqrt (long double x);
Compute square root
Returns the square root of x.

Header <tgmath.h> provides a type-generic macro version of this function.
This function is overloaded in `<complex>` and `<valarray>` (see complex sqrt and valarray sqrt).
Additional overloads are provided in this header (`<cmath>`) for the integral types: These overloads effectively cast x to a `double` before calculations (defined for T being any integral type).

This function is also overloaded in `<complex>` and `<valarray>` (see complex sqrt and valarray sqrt).

### Parameters

x
Value whose square root is computed.
If the argument is negative, a domain error occurs.

### Return Value

Square root of x.
If x is negative, a domain error occurs:

If a domain error occurs, the global variable errno is set to EDOM.
If a domain error occurs:
- And math_errhandling has MATH_ERRNO set: the global variable errno is set to EDOM.
- And math_errhandling has MATH_ERREXCEPT set: FE_INVALID is raised.

### Example

 ``123456789101112`` ``````/* sqrt example */ #include /* printf */ #include /* sqrt */ int main () { double param, result; param = 1024.0; result = sqrt (param); printf ("sqrt(%f) = %f\n", param, result ); return 0; }``````

Output:
 ``` sqrt(1024.000000) = 32.000000 ```