The sqrt()
function in C returns the square root of a number.
You must import the
<math.h>
library to usesqrt()
.
double sqrt(double x)
x
: A floating point value, e.g., 4.0, 5.0, 20.6, etc.sqrt()
returns the square root of x
.
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);}