0
#include<conio.h>
#include<iostream.h>
void main()
{
 clrscr();
 int x,d,a[10],i,sum=0,count=0,n;
 cout<<"Enter no of numbers:";
 cin>>n;
 for(i=0;i<n;++i)
 {
    cout<<"Enter number"<<i+1<<":";
    cin>>a[i];
 }
 for(i=0;i<n;++i)
 { 
   x=a[i];
   while(x!=0)
   { 
      d=x%10;
      sum=sum*10+d;
      x=x/10;
   }
   if(sum==a[i])
       count++;
 }
 cout<<"No of palidromes:"<<count;   
 }

I entered 121,134 and 1331 but the output was always 1. In fact I tried more numbers and still got only 1. Please tell me what's wrong.

CIsForCookies
  • 12,097
  • 11
  • 59
  • 124
SMcCK
  • 155
  • 7

1 Answers1

1

Add sum = 0; after your x=a[i];

CIsForCookies
  • 12,097
  • 11
  • 59
  • 124