Palindrome number in C by R4R Team

Palindrome number:
A number which is same when we read that number in both forward and reverse direction.

Example-
Palindrome number:
12321
123321
454

Not palindrome number:
678
456
123421


program-

#include < stdio.h>
int main()
{
int n,a=0,n1;
printf("Enter number\n");
scanf("%d",&n);
n1=n;
//reverse the number
while(n)
{
a=a*10+n%10;
n=n/10;
}
//now compare number and it's reverse
if(n1==a)
printf("Palindrome");
else
printf("Not palindrome");
return 0;
}


output-

Enter number
12221
Palindrome

Enter number
12331
Not palindrome

-In this program, we take a input of the integer number.
-then we reverse the number and store in variable 'a'.
- then compare both actual number and reverse number, if both are same then input number is considered as a palindrome number otherwise not.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!