sqrt() - Mathematical Function

How is Mathematical Function "sqrt()" used in C++?
How to find the Square root of a number?

Explanation

sqrt() is a Mathematical Function that returns the square root of the given "num" value.

Syntax to find the Square root:


float sqrt( float num);
double sqrt( double num);
long double sqrt( long double num);

Example :



#include <stdio.h>
#include <math.h>
int main ()
{
float r;
r= sqrt(4);
printf ("Square root of of 4:: %f\n", r );
return 0;
}

Result :

Square root of of 4:: 2.000000

In the above example sqrt() is used to find square root of "4".

C++ Tutorial


Ask Questions

Ask Question