Followers

Wednesday, March 14, 2012

CHECKING A LIST OF INTEGERS FOR PALINDROME

#include<iostream.h>
#include<conio.h>

long int rev=0, a[10];
int nmbr;

void revrse(int n)
{

  do
  {
    int temp=n%10;
    rev=(rev*10)+temp;
    n=n/10;
  }while(n!=0);
}

void cmpare(int n)
{
  cout<<"\n\t"<<rev;
  if(n==rev)
    cout<<"PALINDROME";
  else
    cout<<"NON-PALINDROME";
  cout<<"\n";
}

void main()
{
  clrscr();
  cout<<"enter the number of integers : ";
  cin>>nmbr;
  cout<<"Enter the integers : ";
  for(int i=0 ; i<nmbr ; i++)
    cin>>a[i];
  for( i=0 ; i<nmbr ; i++)
  {
    revrse(a[i]);
    cmpare(a[i]);
    rev=0;
  }

  getch();
}
.................................................................
OUTPUT :(click to enlarge the image)

No comments:

Post a Comment