Why do not all test cases work in C++ Palindrome Numers
i worte this code and testet it the testcases 8888 and 12345 do work some of the others dont but i dont know why #include <iostream> using namespace std; #include <math.h> int numbers(int s){ if (s < 10){ return 1 ; } else return 1 + numbers(s/10); } bool isPalindrome(int x,int size) { //complete the function int halfsize = size/2 + size%2; // number 8888 = size 4// halfsize =2 int multi = pow(10,halfsize); int firsthalfnumber = x/multi ; // firsthalfnumber 8876 = 88 double dmulti = pow(10,halfsize); double doublefirstnumber = firsthalfnumber; double secondhalfnumber = (x/dmulti) - doublefirstnumber ; //0.76 secondhalfnumber = secondhalfnumber*(multi);//76 // That both are double firsthalfnumber must become a double if (secondhalfnumber - firsthalfnumber <0.2){ return true; }else return false; } int main() { int n; cin >>n; int size = numbers(n); // how many digits has the number = size if(isPalindrome(n,size)) { cout <<n<<" is a palindrome"; } else { cout << n<<" is NOT a palindrome"; } return 0; }