Square Root of Number program in C++
# Important Points:
- Square root in C++ can be calculated using sqrt() function defined in <math.h> header file.
- sqrt() function takes a number as an argument and returns the square root of that number.
Example:
Given number: 1296
Square root: 36
# Algorithm
- Create a variable number and root.
- Enter the number whose cube root is to be calculated.
- Get the cube root using function sqrt().
Code:
#include<iostream>
#include<math.h>
using namespace std;
int main(){
float number, root;
cout << "Enter number whose root is to be found: ";
cin >> number;
root = sqrt(number);
cout << "Square root of " << number << " is " << root;
return 0;
}
Report Error/ Suggestion