sqrt -- Compute the Square Root

SYNOPSIS

 #include <math.h>

 double sqrt(double x);
 

DESCRIPTION

sqrt computes the square root of its argument x.

RETURN VALUE

sqrt returns the positive square root of x, expressed as a double-precision, floating-point number.

DIAGNOSTICS

For a negative value of x, the function returns 0.0, and the run-time library writes an error message to stderr (the standard error file).

If an error occurs in sqrt, the _matherr routine is called. You can supply your own version of _matherr to suppress the diagnostic message or modify the value returned.

EXAMPLE

  #include <math.h>
  #include <stdio.h>

  main()
  {
     double x;
     puts("Enter the number you want the square root of: ");
     scanf("%lf", &x);
     printf("The square root of %f is %fn", x, sqrt(x));
  }

 

RELATED FUNCTIONS

hypot, _matherr

SEE ALSO

Mathematical Functions

Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.