A palindrome number is a number such that if we reverse it, it will not change. For example some palindrome numbers examples are 121, 212, 12321, -454. To check whether a number is palindrome or not first we reverse it and then compare the number obtained with the original, if both are same then number is palindrome otherwise not.
Source Code:-
#include<iostream.h>
#include<conio.h>
void main()
{ clrscr();
int n, reverse = 0, temp;
cout<<"Program to check Palindrome Condition by-Tarun Rawat\n";
cout<<"\nEnter a number :";
cin>>n;
temp=n;
while( temp != 0 )
{reverse = reverse * 10;
reverse = reverse + temp%10;
temp = temp/10;
}
if(n==reverse)
cout<<"\n"<<n<<" is a palindrome number.\n";
else
cout<<"\n"<<n<<" is not a palindrome number.\n";
getch();
}
Welcome to " way2cplusplus.blogspot.in " Objective of this blog is to implement various Computer Science Engineering Lab problems into C++ programming language. These are basically most common Lab Exercise problems based on the curriculum of engineering colleges throughout the Nation. These lab exercises are also relevant to Data structure. Simply C++ programming zone...
Your blog is very helpful and easy to learn my one request is; Please write C++ program to Check Number is Palindrome or not
ReplyDelete