Palindrome Program in Java

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

 

Output:

Palindrome Program in Java

Leave a Reply

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