0
Why my code is not working. A program show whether a number is palindrome or not using functions
#include <iostream> using namespace std; bool isPalindrome(int x) { //complete the function int n, r,sum=0,temp; while (x>0){ r= x%10; sum = sum *10 +r; x = x/10; } n=temp; if(n==sum) 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;
4 Réponses
+ 1
artwell
What is the value of temp?
0
You had problem with the logic
https://code.sololearn.com/c7TD0mo1LxB5/?ref=app
0
Okay thanks