English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
C ++The sqrt() function in it returns the square root of the number.
√x = sqrt(x)
This function is in<cmath>defined in the header file.
double sqrt(double x); float sqrt(float x); long double sqrt(long double x); double sqrt(T x); //is an integer type
The sqrt() function takes a single non-negative parameter.
An error will occur if a negative parameter is passed to the sqrt() function.
The sqrt() function returns the square root of the given parameter.
#include <iostream> #include <cmath> using namespace std; int main() { double x = 10.25, result; result = sqrt(x); cout << "10.25The square root is " << result << endl; return 0; }
The output when running the program is:
10.25The square root is 3.20156
#include <iostream> #include <cmath> using namespace std; int main() { long x = 464453422; double result = sqrt(x); cout << "464453422The square root is " << result << endl; return 0; }
The output when running the program is:
464453422The square root is 21551.2