C++ program to check whether given number is palindrome or not

This is a very simple program we need to be panic for this.A number is said to be palindrome if reversal of the number is equal to itself.For ex:141 is a palindrome number.To find the reverse of the number we need to get each digit of the given number.For this we shall use the number 10.By dividing the number by 10 we get the last digit as remainder and remaining digits as quotients.Now we shall write the code.

#include
#include
class palindrome
{
  public:
    int n,r,rev,temp;
    void check();
};
void palindrome :: check()
{
   rev=0,temp=n;
   while(temp>0)
    {
      r=temp%10;
      temp=temp/10;
      rev=rev*10+r;
    }
    if(rev == n)
    {
      cout<<"Given number "<<n<<" is palindrome";
    }
    else
      cout<<"Given number "<<n<<" is not palindrome";
}
void main()
{
  clrscr();
  palindrome ob;
  coutob.n;
  ob.check();
  getch();
}

Output:

palin

You can download the code:download

Tech Tip : Now work on your software projects remotely from anywhere on any device(PC/Mac/android/iOS) by loading your software development environment into the cloud with high performance hosted citrix vdi from CloudDesktopOnline. If you prefer a dedicated server, try out dedicated gpu hosting from Apps4Rent with 24*7 impeccable tech-support.

Advertisement

About Anuroop D

Very enthusiastic about technology and likes to share my knowledge through blogging. Has Bachelor's in Information Technology and currently pursuing my PhD in Computer Science.
This entry was posted in C++ and tagged , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s