Saturday, March 12, 2016

C program to check the value is palindrome or not.

#include<stdio.h>
#include<conio.h>
void main()
 {
  clrscr();
  int n,m,sum=0,a;
  printf("Enter a no");
  scanf("%d",&n);
//a integer number is palindrome if original number and number formed by reversing the sequence of //digits are equal
  m=n;
  while(n>0)
   {
    a=n%10;
    sum=sum*10+a;
    n=n/10;
   }
  if(sum==m)
   {
    printf("No is palindrome");
   }
  else
   {
    printf("No is not palindrome");
   }
 getch();
}

output
Enter a no 242
No is palindrome

No comments:

Post a Comment