C++ Program to Check Whether a Number is Palindrome or Not

a palindrome is some number when you reverse them they will be the same example – 191

if reversed 191


#include<iostream>
 
using namespace std;
 
int main()
{
	unsigned long n,num,d,rev=0;
	cout<<"Enter any number: ";
	cin>>n;
	num=n;
 
	do
	{
		d=n%10;
		rev=(rev*10)+d;
		n=n/10;
	}while(n!=0);
	
	if(num==rev)
		cout<<endl<<"Number is Palindrome";
	else
		cout<<endl<<"Number is not Palindrome";
 
	return 0;
}

Output

Enter a number: 12321

Number is Palindrome

Leave a Comment

error: Alert: Content is protected!!