Tuesday, 10 May 2011


(BlueJ,Java)Program to Find Whether No. is Palindrome or Not.

Code:
/* Write a program to find whether no. is palindrome or not.
   Example :
           Input - 12521 is a palindrome no.
           Input - 12345 is not a palindrome no. */
class Palindrome{
      public static void main(int num){
         
          int n = num;
          int reverse=0,remainder;
          while(num > 0){
                remainder = num % 10;
                reverse = reverse * 10 + remainder;
                num = num / 10;
           }
          if(reverse == n)
              System.out.println(n+" is a Palindrome Number");
          else
              System.out.println(n+" is not a Palindrome Number");
     }
}
Comment below for your Query and Feedback... :)

Related Posts :



4 comments:

  1. I want d same program for palidrome words.

    ReplyDelete
  2. was very helpful
    looking forward to better and new programs

    ReplyDelete
  3. How can reverse==number ?

    ReplyDelete
    Replies
    1. Palindrome means that the reverse of the number is same as number . That's why (reverse==n)

      Delete