title: calculating sqare root without use of square root function in c++
body: <p>You are required to write your own algorithm for computing square root. Write a
  pseudocode rst before you go on and write the C++ program. Do not use the
  sqrt function from the math library to compute the square root. Create your own
  square root algorithm.
  2. Your program should cater for all non-perfect square numbers as well as negative
  integers that the user inputs. In these cases the program should prompt the user
  that a perfect square has not been entered.
  3. The program should allow the user three chances to enter a perfect square. If the
  user is not able to enter a perfect square within the three chances then the program
  should exit.
  4. You are to use functions in your C++ program. Create a user dened function
  by the name sqroot. This should be the function where you implement your own
  square root algorithm. This function should return an integer and accept only one
  input argument, that too of type integer.</p>
  
  <p>i have tried but got stuck pliz help</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cmath&gt;
  #include &lt;math.h&gt;
  #include &lt;stdlib.h&gt;
  
  using namespace std;
  
  int main (){
      int test;
      int square;
      int answer;
      int i=0;
  
      cout &lt;&lt; "enter a perfect sqare ";
      cin &gt;&gt; square;
  
      answer = pow(square, 0.5);
  
      test = square % answer;
      if (test==0){
          cout &lt;&lt; "the square is: " &lt;&lt; answer;
  
      }
  
      if (test!=0){
  
          cout &lt;&lt; "enter a perfect sqare ";
          cin &gt;&gt; square;  
          answer = pow(square, 0.5);
  
          test = square % answer;
          cout &lt;&lt; "the square is: " &lt;&lt; answer;
      }
  
  
  
  
  
  
  
  
  
  
  return 0;
  </code></pre>
  
  <p>}</p>