<code>int num = 1001;
int rev = 0;
int rem=0;
while(num!=0){
rem = num%10;
rev =rev*10+rem;
num/=10;
}
System.out.println(rev);
if(rev==num){
System.out.println("pallindrome");
}
else{
System.out.println("not pallindrome");
}
</code>
<code>int num = 1001;
int rev = 0;
int rem=0;
while(num!=0){
rem = num%10;
rev =rev*10+rem;
num/=10;
}
System.out.println(rev);
if(rev==num){
System.out.println("pallindrome");
}
else{
System.out.println("not pallindrome");
}
</code>
int num = 1001;
int rev = 0;
int rem=0;
while(num!=0){
rem = num%10;
rev =rev*10+rem;
num/=10;
}
System.out.println(rev);
if(rev==num){
System.out.println("pallindrome");
}
else{
System.out.println("not pallindrome");
}
I tried printing the value of rev outside the scope and it prints the number same as** num** , but comparing those two number using “==” operator is giving me unexpected result.
Is there a theory behind it??
New contributor
user25090216 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.