Java Program to check Input number is Palindrome or not

import java.util.Scanner;
class scan
{
public static void main(String arg[])
 {
 int r,y=0,temp;
 int x;
  Scanner kb=new Scanner(System.in);
  System.out.println("Enter Number:- ");
  x=kb.nextInt();
  temp=x;
  while(x>0)
   {
        r=x%10;
	y=(y*10)+r;
	x=x/10;
   }
   if(temp==y)
    {
	 System.out.println("Number is palindrome");
	}
	
	else
	{
	 System.out.println("Number is not palindrome");
	}
  
 }
}

OUTPUT:-

Leave a Reply

Your email address will not be published. Required fields are marked *