Palindrome number


Palindrome number
---------------------
A palindromic number (also known as a numeral palindrome or numeric palindrome) is a number
that remains the same when its digits are reversed.

Like 16461, for example, it is “Palindrome”.


//Source Code 
import java.util.Scanner;
public class PalindromeNumber
  {
      public static void main(String args[])
         {
             Scanner in=new Scanner(System.in);
             int num , rev = 0 , rd , ncopy;
             System.out.print("Enter a Number To Check : ");
             num = in.nextInt();
             ncopy=num;
             while(num!=0)
                {
                    rd=num%10;
                    rev=rev*10+rd;
                    num=num/10;
                      }
           
                if(rev==ncopy)
                   {
                       System.out.print("It is a Palindrome Number . ");
                        }
                else
                  {
                       System.out.print("It is Not a Palindrome Number . ");
                       }
                   
               }
         }
       
// Sample Input :
 Enter a Number To Check : 121
// Sample Output:       
 It is a Palindrome Number .


// Sample Input :
 Enter a Number To Check : 123
// Sample Output:       
 It is Not a Palindrome Number .



Post a Comment

0 Comments