The question is to check weather the entered number is a palindrome or not and my code is as belows...
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n,num,digit,rev=0;
cout<<"\n"<<"input the number";
cin>>num;
n=num;
do
{
digit=num%10;
rev=(rev*10)+digit;
num=num/10;
}
while(num!=0);
cout<<"the reverse of the number is:"<<rev<<"\n";
if(n==rev)
cout<<"the number is palindrome";
else
cout<<"the number is not palindrome";
}
In this the mistake is that for some palindromes like "32123" it says yes it is a palindrome. But for others like "4321234" it says no it is not a palindrome. This is the main reason for my confusion. Please some one please help me.

New Topic/Question
Reply




MultiQuote




|