After reversing if you are getting same number it means you are reversing palindrome number.
to reverse the all digit and get same number is symbol of palindrome number.
Lets take examples
121 after reverse it we will get 121. so we can say 121 is palindrome number.same is with 999=999.
12=21 not palindrome number .Have you seen mirror same functionality is working here.
But here is digit not your face.so we are going to learn about palindrome number and execution.
we can reverse string also like did=reverse(did)=did but i dont know about words just think about digits .ok i think there is enough explanation now time is to do something real .
Let's concentrate to source code in c program.sorry about c language we are going to learn c++.everything is same in c just little about scanf and printf
How to write c++ palindrom number Program with source code
int pali(int); // function name pali
void main()
{
int n,a;
clrscr();
cout<<"\n enter the number=";
cin>>n; // accepting number from user
a=palindrom(n);
if(n==a) // cheking after reversing number is same or not
cout<<"\n number is palindrom"; // yes it is
else
cout<<"\n number is not palindrom"; //no it is not
getch();
}
int palindrom(int x) //
{
int r,sum=0;
while(x!=0) // till number will there
{
r=x%10; taking mode so we can get at least one number
sum=sum*10+r; //addition
x/=10; //division
}
return(sum);//function calling
}
in c or c++ do execution with your own .execution will give you correct logic and method to understand program logic.
0 comments: