# PHP Math functions sqrt

``float sqrt ( float \$number )``
\$number is the input value for which square root is required.

We can get square root of a math number by using sqrt function
Here are some examples
``````echo sqrt(16);// output is 4
echo sqrt(20);// output 4.4721359549996
echo sqrt(-9);// output NAN
echo sqrt(-2.5);// output NAN
echo sqrt(1);// output 1
echo sqrt(-1);// output NAN
``````
Note that for negative numbers we will get output as NAN mean not a number . We can verify this output by using is_nan function.

## Hypotenuse of a right angle triangle

In a right angled triangle we have two sides of right angle as a & b. The hypotenuse of the triangle is known as h . We have to find the value of it.

We will use POW function to get the square of each side. Then we will add them and take the square root of the sum.

Here is the code.
``````\$a=3;  // One side
\$b=4;  // One side
\$h=sqrt(pow(\$a,2)+pow(\$b,2));
echo \$h;
``````
Output is 5 ## Subscribe

* indicates required
Subscribe to plus2net plus2net.com

Post your comments , suggestion , error , requirements etc here .