int main(){
int n, val, i,sum(0),temp,m(0);
cout<<"Enter the number: ";
cin>>n;
temp=n;
while(n>0){
n/=10;
m++;
}
n=temp;
while(n>0){
m--;
i=n%10;
val= i*pow(10,m);
cout<<"Power: "<<val<<endl;
sum=sum+val;
n/=10;
}
if(temp==sum){
cout<<"Palindrome";
}
else{
cout<<"Not Palindrome";
}
return 0;
}
Here in this part:
val= i*pow(10,m);
cout<<"Power: "<<val<<endl;
If m=2 and i=1 then this should give 100 but I'm getting 99 as output. This is happening only for the first val and for the other it shows the perfect value
Can anyone tell me what I'm doing wrong