Well, it's printing "not a palindrome" for all the numbers i punch
Including many palindromes..
Well, it's printing "not a palindrome" for all the numbers i punch
Including many palindromes..
/* the thing is that i need to check if a given number (n) is a palindrome. i also used limits.h to identify if the number is
is exceeding the limit. i came up with this beut it's no good. any ideas? */
#include <iostream>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
using namespace std ;
int main ()
{
int a, n, m=0, t ;
cout<<"Enter query number:"<<endl ;
cin>>n ;
t=n ;
while (n)
{
{
a=n%10 ;
n=n/10 ;
m=m*10+a ;
{
if (INT_MAX-n<a)
cout<<"overload" ;
}
}
if (t==m)
cout<<t<<"this number is already a palindrome"<<endl ;
else
cout<<t<<"this number is not a palindrome"<<endl ;
}
return 0 ;
}
//A1 = 1
//An = An-1 +sqrt(An-1) for n > 1.
//i need to find An of the series according to the estimation An=(n^2)/4
//how do i write a member of the series, let's say "An" in the code and to apply "n>1" in the code?