C Program check whether given number is palindrome or not


#include<stdio.h>

main() 

{

 int dummy,n,rev=0,x;

 printf("Enter a number\n");

 scanf("%d",&n);

 dummy=n;

 while(n>0)

 {

   x=n%10;

   rev=rev*10+x;

   n=n/10;

 }

 if(dummy==rev)

 printf("The given number %d is a palindrome\n",rev);

 else

 printf("The given number %d is not a palindrome\n",rev);

}
Output:-
Enter a number
131
The given number 131 is a palindrome

Post a Comment

If you have any doubts, Please let me know
Thanks!

Previous Post Next Post