title: Program to calculate square root c++
body: <p>I am making a C++ program to calculate the square root of a number. This program does not use the "sqrt" math built in operation. There are two variables, one for the number the user will enter and the other for the square root of that number. This program does not work really well and I am sure there is a better way to do so:</p>
  
  <p><strong>Here is my full code:</strong></p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main(){
    int squareroot = 0;
    int number;
  
    cout &lt;&lt; "enter a number sp that i can calculate its squareroot" &lt;&lt; endl;
  
    cin &gt;&gt; number;
  
    while (squareroot * squareroot != number){
  
        squareroot+=0.1;
  
  }
  cout &lt;&lt; "the square root is" &lt;&lt; squareroot &lt;&lt; endl;
  return 0;
   }
  </code></pre>
  
  <p>I know there must be a better way. Pls help. Looked through Google but don't understand the complex programs there as I am still a beginner. </p>
  
  <p>Thanks in advance. </p>