Write a C++ Program to find the Square Root of a Number. In this program, we used the sqrt math function (sqrtResult = sqrt(number)) to get the result.
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
double number, sqrtResult;
cout << "\nPlease Enter any Number to find Square root = ";
cin >> number;
sqrtResult = sqrt(number);
cout << "\nThe Sqauer root of a " << number << " = " << sqrtResult;
return 0;
}

In this program code, we used the math pow function to find the square root of a number.
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
double number, sqrtResult;
cout << "\nPlease Enter any Number to find Square root = ";
cin >> number;
sqrtResult = pow(number, 0.5);
cout << "\nThe Sqauer root of a " << number << " = " << sqrtResult;
return 0;
}
Please Enter any Number to find Square root = 265
The Sqauer root of a 265 = 16.2788