C++ palindrome number help!
The test case 3 and 4 (which are hidden) are not working with this code. Can anyone please tell me what's wrong with the code? Thankyou. #include <iostream> #include <cmath> using namespace std; bool isPalindrome(int x) { //complete the function int len = sizeof(x); int revSum = 0; int tempX = x; for (int i = 0; i < len; i++) { revSum += (tempX % 10) * pow(10, len - i - 1); tempX /= 10; } if (revSum == x) { 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; }