C++ Program to check if Number is Palindrome or not
#include<iostream>
using namespace std;
int main()
{
int i,n,t,r=0,x=0,s=0;
cout<<"Enter a number :";
cin>>n;
x=n;
while(n!=0)
{
t=n%10;
s+=t;
r=(r*10)+t;
n=n/10;
}
if(x==r)
{
cout<<"The number is palindrome";
}
else
cout<<"The number is not a palindrome\n";
}
Comments
Post a Comment