Program:

import java.util.Scanner;
public class PalindromeNum
{
 public static void main(String[] args)
 {
 int r, n, sum=0, temp;
 Scanner sc = new Scanner(System.in);
 System.out.print("Enter a number: ");
 n=sc.nextInt();
 temp=n;
 while(n>0)
 {
 r = n%10;
 sum = (sum*10)+r;
 n=n/10;
 }
 if(temp==sum)
 System.out.println("Entered number is a Palindrome");
 else
 System.out.println("Entered number is not a Palindrome");
 }
}

 

Output:

Enter a number: 456654
Entered number is a Palindrome

You can download the pdf file of Palindrome Number.

Advertisements