title: finding the number of perfect squares in the given range
body: <p>I am trying to find out the number of perfect squares in the given range. The method I am following is provided on: <a href="http://burningmath.blogspot.in/2013/09/how-to-check-if-number-is-perfect-square.html" rel="nofollow">digital_root</a></p>
  
  <p>The code I have implemented is not giving correct answers sometimes because This method does not consider the numbers like 10,1000 etc. </p>
  
  <p>Please help me to work out this method.</p>
  
  <pre><code> int cot=0;
  void squares(int a,int b){
      if(a==b){
          int digit,digit_root=0,no;
          no=a;
          digit=no%10;
          if(digit==2||digit==3||digit==7||digit==8){
          }else{
              no=a;
              while(no&gt;0){
              digit=no%10;
              if((digit==0)||(digit==9)){
  
              }else{
                  digit_root=digit_root+digit;
                  digit_root=digit_root%9;
              }
              no=no/10;
      }
              if(digit_root==0||digit_root==7||digit_root==1||digit_root==4){
                  if(digit_root==1){
                      if(a)
                  }
                  cot++;
              }
          }
  
          }else{
          int c=(a+b)/2;
          squares(a,c);
          squares(c+1,b);
      }
  
  
  }
  
  int main() {
     int a,b,t;
      cin&gt;&gt;t;
      for(int i=0;i&lt;t;i++){
       cin &gt;&gt; a&gt;&gt;b;
      squares(a,b);   
          cout &lt;&lt; cot&lt;&lt;endl;
          cot=0;
      }
  
      return 0;
  }
  </code></pre>