+ 1
Another one with some bugs help me fixing it
2 Respostas
+ 2
Instead of trying to explain myself with a long post written in poor English, I just give you my solution.
I know it's hard to understand programs written by someone else, but try to do it.
https://code.sololearn.com/c0wtMk3i75gc/?ref=app
+ 1
You are comparing sum to n. n is zero at the end of function as n is modified in each loops, so comparing sum with n gives false. You save the value of n in temporary variable and compare sum with it. The below code might help
bool isPalindrome(int n){
int temp=n;
while (n > 0){
int y = n%10;
int sum = 0;
sum += sum * 10 + y;
n = n/10;
if (sum == temp){
return true;}
}
return false;
}