Add header:
#include<math.h>
Note: use abs(), sometimes at the time of evaluation sqrt() can take negative values which leave to domain error.
abs()- provides absolute values;
example, abs(-3) =3
Include -lm at the end of your command during compilation time:
gcc <filename.extension> -lm