0

I keep getting this compiler error, but I have an argument present. I am trying to find if a number is divisible by 10 WITHOUT using %

int main() {

    long int x;
    long int y;
    long int z;
    

    cout << "Give me any integer and I'll tell you if it is divisble by 10!\n";
    cin >> y;   

    /* x = y / 10;              // this should cut the last number
    z = x * 10;                 // then we need to multiply the divided number by 10, if we get the same answer the should be equal
    */
    
    
    
    if (div(y) == 1) {      // i keep getting errors calling this function saying it takes 1 argument, but there is one

        cout << "Since your remainder is 0, your number is divisible by 10\n";
    }
    else {
        cout << "Not divisible by 10\n";
    }

    

    return 0;
}
    
long int div( long int y ) {

    long int a = y;

    long int x = y / 10;
    long int z = x * 10;
    
    if (z == y) 
        return 1;
    else
        return 0;
}
NathanOliver
  • 171,901
  • 28
  • 288
  • 402

0 Answers0