What is sqrt() in C?
The sqrt() function in C returns the square root of a number.
You must import the
<math.h>library to usesqrt().
Syntax
double sqrt(double x)
Parameters
x: A floating point value, e.g., 4.0, 5.0, 20.6, etc.
Return value
sqrt() returns the square root of x.
Example
In the example below, we use the sqrt() function to find the square root of some numbers.
#include <stdio.h>// include the math libarary so as to use sqrt() method#include <math.h>// main functionint main () {// Print square root of some valuesprintf("Square root of %lg is %lg\n", 4.0, sqrt(4) );printf("Square root of %lg is %lg\n", 16.0, sqrt(16.0) );printf("Square root of %lg is %lg\n", 3.3, sqrt(3.3) );return(0);}