Check Palindrome Using c++

 #include <iostream>


using namespace std;


int main()

{

    int n,num=0,r;

    cin>>n;

    int a = n;

    while(n>0){

         r = n%10;

         num = num*10 + r;

         n/=10;

    }

//     cout<<num;

    if(num==a)

    cout<<"Palindrome";

    else

    cout<<"Not Palindrome";

    cout<<endl;


    return 0;

}


No comments:

Post a Comment

Operator Overloading in C++

#include<iostream> using namespace std; class Complex { private: int real, imag; public: Complex(int r = 0, int i = 0){       re...