Palindrome number in c++






Palindrome number in c++


#include<iostream>
int main(){
    int num,r,sum=0,temp;

    cout << "Enter a number: ";
     cin >> num;

    for(temp=num;num!=0;num=num/10){
         r=num%10;
         sum=sum*10+r;
    }
    if(temp==sum)
         cout << temp << " is a palindrome";
    else
         cout << temp << " is not a palindrome";

    return 0;
}




Algorithm:
**


1 comment:

Anonymous said...

What if x is founded as palindrome and the squared of x is also a palindrome

For ex

x xsquared
101 10201
111 12321
121 14641

and so on...

can you help me in this? : >