Tuesday, 5 September 2017

C-Program to find whether given number is palindrome or not



#include<stdio.h>

int 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);
 return 0;
}

No comments:

Post a Comment