Friday, February 13, 2015

Java program to check whether a given number is palindrome or not

Java program to check whether a given number is palindrome or not

class Palindrome
{
public static void main(String...s)
{
int n,m,rev=0,i;
n=Integer.parseInt(s[0]);
m=n;

while(n!=0)
{
i=n%10;
rev=(rev*10)+i;
n/=10;
}

if(m==rev)
System.out.println("
Number is 


palindrome");
else
System.out.println("
Number is not 


palindrome");
}
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.