Q:

Write a Java Program to find given number is Palindrome or Not

belongs to collection: Java Number Solved Programs

0

A Palindrome number is a number that remains the same when its digits are reversed.

Like 12321, for example: we take 121 and reverse it, after revers it is same as original number.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

SOURCE CODE ::

import java.util.Scanner;
class Palindrome 
{
public static void main(String[] args) 
{
        int a,no,b,temp=0;
        Scanner s=new Scanner(System.in);
        System.out.println("Enter any num: ");
        no=s.nextInt();
        b=no;
        while(no>0)
            {
            a=no%10;
            no=no/10;
            temp=temp*10+a;
        }
        if(temp==b)
        {
            System.out.println("Palindrome");
        }
        else
        {
            System.out.println("not Palindrome");
        }
}
}

OUTPUT ::

Enter any num: 
1221
Palindrome

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Write a Java Program to Find Sum of Digits of give... >>
<< Write a Java Program to find Largest among three N...