find the error in the code:
#include
int main()
{
int n, rev = 0, temp;
std::cin>>n;
while(n > 0){
int r = n % 10;
rev = rev * 10 + r;
n = n % 10;
}
if(rev == temp)
std::cout<<"Palindrome";
return 0;
}
Answers
Answered by
0
Answer:
#include <iostream>
using namespace std;
int main()
{
int n,rem,rev=0,temp;
cin>>n;
temp=n;
while(n>0)
{
rem = n%10;
rev = rev*10+rem;
n = n/10;
}
if(temp == rev)
cout<<"Palindrome\n";
else
cout<<"Not a Palindrome\n";
return 0;
}
Explanation:
Hope this helps
Similar questions