Java program to find whether no. is palindrome or not

Saturday, February 5th, 2011
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* 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(String args[]){
		int num = Integer.parseInt(args[0]);
		int n = num; //used at last time check
		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");
	}
}
Avatar of surajk

Author Name :
surajk

Total : 8 Comments


8 Responses to “Java program to find whether no. is palindrome or not”

  1. Bhavna mulani says:

    Thanks…it is a very helpful to me…thnks a lot

  2. Ravi says:

    where it get input for number sir

  3. Mounika says:

    Thank u very much.

  4. Priya says:

    thank u ….

  5. Gokul says:

    Here is another way to check palindrome in Java

  6. navya says:

    its superb

  7. sashi says:

    Plz dont post adds on main content.

    It is too worse….

  8. Aditya c says:

    Thanks
    Also refer this for PALINDROME OF A NUMBER AND A STRING IN SAME USER INPUT

    http://knowitenjoyit.blogspot.in/2013/03/palindrome-number-string-java.html

Leave a Reply

Question and Answer
C/C++ Unix & Linux Wordpress
Source codes
C C++ Java

Free email signup

Email: