sqrt

calculate the non-negative square root of a number

Synopsis:

#include <math.h>
double sqrt( double x );

Description:

The sqrt() function computes the non-negative square root of x. A domain error occurs if the argument is negative.

Returns:

the value of the square root

When the argument is outside the permissible range, the matherr() function is called. Unless the default matherr() function is replaced, it will set the global variable errno to EDOM, and print a “DOMAIN error” diagnostic message using the stderr stream.

See also:

errno, exp(), log(), pow(), matherr()

Examples:

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

void main()
  {
    printf( "%f\n", sqrt(.5) );
  }

produces the output:

0.707107

Classification:

ANSI

Systems:

Math