Check if an integer is a palindrome
Anonymous
boolean isPalin(int n){ int digit; int reverse = 0; while (n > 0){ digit = n % 10; // gets the last digit. reverse = reverse * 10 + digit // forms a reverse number n = n / 10; // cuts short the last digit } return n == reverse; }
Check out your Company Bowl for anonymous work chats.