Find Square Root of a Number in C++
Hello friends, Hitesh is here. Today we will learn about how to write complete code of
Find Square Root of a Number in C++. Square root of any number means 0.5 power of number. Here this concept is applicable in programming. And another way to direct use predefined function sqrt() to calculate square root of number.
Square Root Code
#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
No comments:
Post a Comment