Sunday, 17 February 2019

C++ Program to Check whether the given number is palindrome or not

#include <iostream>

using namespace std;

int main()
{
    int n,num,m,r=0;
    cout<<"Enter The Number\n";
    cin>>n;
    num=n;
    do
    {
        m=n%10;
        r=(r*10)+m;
        n=n/10;
    }while(n!=0);

    if (num==r)
        cout<<"\n"<<num<<" is Palindrome\n";
    else
        cout<<"\n"<<num<<" is not Palindrome\n";
    return 0;
}

OUTPUTE:

Enter The Number
121

121 is Palindrome

No comments:

Post a Comment