Palindrome Number Program in C++
Palindrome number means whenever you reverse any number; result will be same like original number. Here very simple code for Palindrome Number Program in C++
#include<iostream.h>
#include<conio.h>
void main()
{
int palindrome, reverse=0, num=0;
cout<<"Enter number: ";
cin>>palindrome;
temp=palindrome;
for(int i=1;palindrome!=0;i++)
{
num=palindrome%10;
palindrome=palindrome/10;
reverse=num+(reverse*10);
}
if(reverse==temp)
{
cout<<temp<<" is a Palindrome Number";
}
else
{
cout<<temp<<"is not a Palindrome Number";
}
getch();
}
Output:
Enter any number: 154
154 is not Palindrome Number
No comments :
Post a Comment