Monday, June 18, 2012

To check whether the entered number is palindrome or not


/* To check whether the entered number is palindrome or not */
#include<stdio.h>
#include<conio.h>
void main()
{
  int num,temp,a,rev=0;
  clrscr();
  printf("Enter the number: ");
  scanf("%d",&num);
  temp=num;
  while(num!=0)
  {
    a=num%10;
    rev=rev*10+a;
    num=num/10;
  }
  if(temp==rev)
    printf("\n\nGiven Number %d is Palindrome!",temp);
  else
    printf("\n\nGiven Number %d is NOT Palindrome!",temp);
  getch();
}
 
OUTPUT
Enter the number: 1221
 
 
Given Number 1221 is Palindrome!

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.