Home >>C Math Functions >C math sqrt() function

C math sqrt() function

C math sqrt() function

The C math sqrt() function is used to return the square root of the given argument x. It takes a single argument (in double) and returns the square root (also in double). This function is defined in math.h header file.

Syntax:
double sqrt(double x)

Parameter Values

xIt is the floating point value.

Here is an example of sqrt() function:

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

Output:
Square root of 4.000000 is 2.000000
Example-2

#include <stdio.h>
#include <math.h>
int main () 
{
printf("Square root of %lf is %lf\n", 64.0, sqrt(64.0) );
return(0);
}

Output:
Square root of 64.000000 is 8.000000