palindrome number in C++ by R4R Team

Palindrome number:
A number which is same when we read that number in both forward and reverse direction.

Example-
Palindrome number:
12321
123321
454

Not palindrome number:
678
456
123421

program:

#include < iostream>
using namespace std;
class r4r
{
public:
int reverse(int n)
{
int n1=0;
while(n)
{
n1=n1*10+n%10;
n=n/10;
}
return n1;
}
};
int main()
{
int n;
r4r obj;
cout<<"Enter any number"<< endl;
cin>>n;
if(n==obj.reverse(n))
cout<<"Number is palindrome";
else
cout<<"Number is not palindrome";
return 0;
}


output-

Enter any number
1331
Number is palindrome

Enter any number
345
Number is not palindrome




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!