Square root in C++ can be calculated using sqrt() function defined in math.h header file. This function takes a number as an argument and returns the square root of that number.
Below I have shared a program to find square root in C++. If you have any problem then you can freely ask it by commenting below.
Program to Find Square Root of a Number in C++
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
float sq,n;
cout<<"Enter any number:";
cin>>n;
sq=sqrt(n);
cout<<"Square root of "<<n<<" is "<<sq;
return 0;
}
Output:
Enter any number:9
Square root of 9 is 3
ThanX Dear…
Thanks to all of you…
One Of The Best C teaching website for Beginners !!
Thanks Sachin!
it’s good.thanx man
ts ayt.thnx
I want the same program but for n numbers
i wanna to teach c++ for my universty course i failed in my mids
can anyone help me ?