Check whether a number is palindrome or not ..
#include<iostream>
using namespace std;
bool isPanlindrome(int n)
{
int rev = 0;
int num = n;
while(n)
{
rev = rev * 10 + (n%10);
n = n /10;
}
if(num && num == rev)
return true;
return false;
}
int main()
{
int number = 0;
cout<<"Enter the number: ";
cin>>number;
cout<<number<<" is Panlindrome ?."<< (isPanlindrome(number)? "Yes !!": "No :(!!");
cout<<endl;
return 0;
}
No comments:
Post a Comment