 # C sqrt()

The sqrt() function is defined in the math.h header file. It helps to returns the square root of the given argument.

``````
double sqrt(double x); #where x should be in double
```
```

Also, two functions sqrtf() and sqrtl() were used with type float and long double respectively.

``````
float sqrtf(float x);
long double sqrtl(long double x);
```
```

## sqrt() Parameters:

The sqrt() function takes a single parameter in double. We can explicitly convert the type to double to find the square root of type int, float, or long double using the cast operator.

Parameter Description Required / Optional
double value whose square root needs to be found Required

## sqrt() Return Value

The return value of sqrt() function is a number in double.

Input Return Value
double value square root(in double)

## Examples of sqrt()

### Example 1: Working of sqrt() function in C?

``````
#include <stdio.h>
#include <math.h>
int main()
{
double N = 25, squareR;

squareR =  sqrt(N);
printf("The Square root of given %lf is  %lf", N, squareR);

return 0;
}
```
```

Output:

```
The Square root of given 25.000000 is  5.000000

```

### Example 2: How sqrt() function worked in C?

``````
#include <stdio.h>
#include <math.h>
int main () {
printf("The Square root of %lf is %lf\n", 4.0, sqrt(4.0) );
printf("The Square root of %lf is %lf\n", 5.0, sqrt(5.0) );

return(0);
}
```
```

Output:

```
The Square root of 4.000000 is 2.000000
The Square root of 5.000000 is 2.236068
```