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;

26th Jul 2021, 9:36 AM
artwell
artwell - avatar
3 Answers
+ 1
artwell What is the value of temp?
26th Jul 2021, 10:02 AM
AÍąJ
AÍąJ - avatar
0
26th Jul 2021, 10:26 AM
Baribor Saturday
Baribor Saturday - avatar
0
Okay thanks
26th Jul 2021, 10:27 AM
artwell
artwell - avatar