class PalindromeOfNumber
{
public static void main(String[] args)
{
int original=12345;
int o=original;//Stored for reference
int reverse=0;
while( original != 0 )
{
reverse = reverse * 10;
reverse = reverse + original%10;
original = original/10;
}
if (o==reverse)
{
System.out.println("Number is palindrome");
}
else
{
System.out.println("Number is not a palindrome");
}
}
}
{
public static void main(String[] args)
{
int original=12345;
int o=original;//Stored for reference
int reverse=0;
while( original != 0 )
{
reverse = reverse * 10;
reverse = reverse + original%10;
original = original/10;
}
if (o==reverse)
{
System.out.println("Number is palindrome");
}
else
{
System.out.println("Number is not a palindrome");
}
}
}
0 comments:
Post a Comment