palindrome end of project, c++
I personally prefer the "string based" based path to completing this project, however this is only after I failed to adapt the crazy maths solution i found off the internet, I'm hoping someone can point out where I've gone wrong in trying to solve the bool type problem. #include <iostream> using namespace std; bool isPalindrome(int x) { int num, digit, rev; x = num; do { digit = num % 10; rev = (rev * 10) + digit; num = num / 10; } while (num != 0); if (x == rev) { return true; } else { return false; } } int main() { int n; cin >>n; if(isPalindrome(n)) { cout <<n<<" is a palindrome"; } else { cout << n<<" is NOT a palindrome"; } return 0; }