import java.util.*; public class Main { public static void main(String[] args) { int n; Scanner s=new Scanner(System.in); System.out.println("Enter a number: "); n=s.nextInt(); int palindrome,r,rev=0; palindrome = n; while (n > 0) { r = n % 10; rev = rev * 10 + r; n = n / 10; } if (rev == palindrome) { System.out.println(" The given no is palindrome "+ rev); } else { System.out.println("The given no is not palindrome " + rev); } } }
Enter a number: 212
The given no is palindrome 212
Enter a number: 1228
The given no is not palindrome 8221