Project Euler #171: Finding numbers for which the sum of the squares of the digits is a square

  • + 0 comments

    what's the error in it can anyone tell that...

    //Project Euler #171: Finding numbers for which the sum of the squares of the digits is a square
    
    #include<iostream>
    #include<math.h>
    using namespace std;
    
    bool isPerfectSquare(long double x)
    {
    // Find floating point value of
    // square root of x.
    long double sr = sqrt(x);
    
    // If square root is an integer
    return ((sr - floor(sr)) == 0);
    }
    
    
    int main(){
    
    unsigned long int range=0100,sum=0,rem=0,bsum=0,lo=0;
    cin>>range;
    unsigned long int hold;
    for(int i=1;i<=range;i++){
    
    
        hold=i;
        while(hold>0){
            rem=hold%10;
     hold/=10;
             sum+=rem*rem;
               lo+=sum;
              sum=0;
    
    
    
        }
    
         if (isPerfectSquare(lo)){
            bsum+=i;
    
         }
         lo=0;
    }
    cout<<bsum;
    
    }