Important point:
- Import math library and use built in square root function which is sqrt()
# Algorithm
- Create variable num and root.
- Enter the number whose root is to be calculated.
- Get the root using function sqrt().
#include<iostream> #include<math.h> using namespace std; int main(){ float num; float root; cout << "Enter number to find square root: "; cin >> num; root = sqrt(num); cout << "Square root of" << number << " is " << root; return 0; }
0 Comments