Making a C++ application to determine a number's square root.
The built-in arithmetic operator "sqrt" is not used in this application.
There are two variables: one for the user-inputted integer and the other for the number's square root.
This software does not function very well, and I am certain that there is a more effective method to accomplish it:
Here is my full code:
#include <iostream>
using namespace std;
int main(){
int squareroot = 0;
int number;
cout << "enter a number sp that i can calculate its squareroot" << endl;
cin >> number;
while (squareroot * squareroot != number){
squareroot+=0.1;
}
cout << "the square root is" << squareroot << endl;
return 0;
}
I'm sure there must be a better approach.
help please
I looked via Google, but since I'm still learning, I don't comprehend the sophisticated programmes there.
I appreciate it.