Guys I got one doubt in palindrome. I write one program for Number palindrome. It executes Successfully, But when I enter 333 I got the correct output, When I put 111 I got the wrong output. I don't know what is wrong, Because when I execute above 3 that will give correct output, But when I give below 3 I got the wrong output. Plz, help me to What I did a mistake.
public class Practice1 {
public static void main(String[] args) {
int num = 121, res = 0, var = 0, c = num;
for (int i = 1; i <= num; i++) {
res = num % 10;
var = var * 10 + res;
num = (num) / 10;
}
if (var == c) {
System.out.println(c + " is a Palindrome Number");
} else {
System.out.println(c + " is not a Palindrome Number");
}
}
}