title: To find the nearest perfect square if the number entered is not a perfect square?
body: <pre><code>#include &lt;iostream&gt;
  #include &lt;limits&gt;
  #include &lt;cmath&gt;
  
  using namespace std;
  
  int main()
  {
      int number;
      cout &lt;&lt; "Enter the number whose sqare root needs to be calculated";
      cin &gt;&gt; number;
      cout &lt;&lt; "Square root of " &lt;&lt; number &lt;&lt; " is " &lt;&lt; (int)sqrt((float)number)  &lt;&lt; " OR " &lt;&lt; sqrt((float)number) &lt;&lt; endl;
      if( (int)sqrt((float)number) == sqrt((float)number) )
      cout &lt;&lt; "The number is a perfect sqaure";
      else
      cout &lt;&lt; "The number is not a perfect square";
      //To find the nearest perfect square if the number entered
     // is not a perfect square?
  
      return 0;
  }
  </code></pre>
  
  <p>I hope what i have done to check the perfect squares is OK, but furthermore I want to
  find out the number nearest perfect square if the number entered is not a perfect square
  Any Ideas</p>