|
|
sqrt() - Mathematical Function
|
Tutorials

Cpp

|
Topic |
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".
|
| Note |
C++ is one of the most used programming languages in the world. Also known as "C with Classes".
Hope you enjoy this tutorial. Do send your feedback or suggestions on this C++ tutorial. This is a copyright content.
|
|
|
|